Click here to Skip to main content
13,404,627 members (36,509 online)
Rate this:
Please Sign up or sign in to vote.
See more:
When a user clicks browse, he selects a .dmp file from str2 = "d:\data\dump\xxx.dmp" and clicks on proceed button, to save to another PC in a folder on that PC, in ls_backupthumb2 = "\\\c:\tdata\"
FileUpload fileUpload1.PostedFile.SaveAs(Path.Combine(ls_backupthumb2, str2))

Is this correct? Please give an example with this type or a link to a reference

A friend suggested using impersonation but I am not familiar with it.

It is a web application in VB.NET.
Posted 26-Jan-11 17:15pm
Updated 26-Jan-11 18:06pm
Indivara 26-Jan-11 23:04pm
Fixed language a bit...

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

FileUpload fileUpload1;

fileUpload1 should already have the uploaded file, you don't need the path on the client's local drive.

FileUpload.SaveAsfileUpload1.PostedFile.SaveAs saves to the web server (where the application runs), so it will only work if the IIS process has write access to the target path.

What is the network path you want to write to? Is it on the server or elsewhere?

BTW \\\c:\tdata\ makes no sense, you can't access C:\ like that, maybe \\address\c$ (depending on OS).

-- update --
Details of comment below (quick & dirty method)
  • Share an arbitrary folder on the machine to save to. Say C:\shared\websave\ is shared with name websave, then you access it as \\\websave
  • Grant full access to the Everyone group to the folder share
  • fileUpload.PostedFile.SaveAs(@"\\\webshare\filename.dmp");
    (you'll have to convert to VB, I can't write it offhand)
  • Cross fingers and hope it works
A better method is to get the web application to log in to the target machine, but I can't recall what you need to use. Maybe if I have time...
Let's hope someone else replies with a better solution.

-- update 2 --[^]

This shows how to impersonate a user. I have tried it in the past and it works out of the box, but that is for logging onto the local machine. Experiment with it; for example try \\remotehostname\remotehostuser as the user name.

-- update 3 --
Sorry, I have never heard of the FSO until now. Judging from the documentation, you probably could use it, but will still need a method to log on from the server (from inside the web app) to the target (where you
save the uploaded files)

From what you described, the scenario is like this -
There are 3 computers involved
[1] web server where the application runs (on IIS)
[2] client PC which uses the web app, via browser
[3] target PC where you save files

You need to allow [1] to log on to [3] from within the app running on IIS, and save files there, without letting anyone else (including [2]) to access the shared folder.

I can't find a good sample immediately. Got to go now, look into the one above in the mean time.
Sandeep Mewara 27-Jan-11 0:15am
Comment from OP:
thanks for reply.

but how can i copy the particular uploaded file into another laptop or pc(my co-staff) whose

os - microsoft windows xp Professional version 2002 service pack2

can u help me the coding for this ...pls its needed urgent today
Indivara 27-Jan-11 1:22am
Thanks! replied to OP.
agrace27 27-Jan-11 0:57am
thanks for reply.

but how can i copy the particular uploaded file into another laptop or pc(my co-staff) whose

os - microsoft windows xp Professional version 2002 service pack2

can u help me the coding for this ...pls its needed urgent today
Indivara 27-Jan-11 1:01am
A proper fix will take me some time to figure out, if you want a quick and dirty fix, grant full access to "Everyone" (group) to some particular shared folder, and get the web application to save there. Absolutely no security, not recommended. Maybe somebody else can help with a better method. See updated answer above for details
agrace27 27-Jan-11 1:59am

The given path's format is not supported.
Server Error in '/HQSLEX' Application.
The given path's format is not supported.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NotSupportedException: The given path's format is not supported.

Source Error:

Line 130: ' File.Copy(str1, Path.Combine(ls_backupthumb2, Path.GetFileName(str1)))
Line 131:
Line 132: FileUpload1.PostedFile.SaveAs("\\\c:\tdata\GN_APPACCESS.DMP")
Line 133:
Line 134:

Source File: c:\inetpub\wwwroot\HQSLEX\data\ManualTollDataUpload.aspx.vb Line: 132

Stack Trace:

[NotSupportedException: The given path's format is not supported.]
System.Security.Util.StringExpressionSet.CanonicalizePath(String path, Boolean needFullPath) +7486447
System.Security.Util.StringExpressionSet.CreateListFromExpressions(String[] str, Boolean needFullPath) +278
System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList) +87
System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, AccessControlActions control, String[] pathList, Boolean checkForDuplicates, Boolean needFullPath) +46
System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) +637
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) +61
System.IO.FileStream..ctor(String path, FileMode mode) +55
System.Web.HttpPostedFile.SaveAs(String filename) +99
data_ManualTollDataUpload.Button1_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\HQSLEX\data\ManualTollDataUpload.aspx.vb:132
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053
Indivara 27-Jan-11 2:01am
I already told you, there is no C: in the path "\\\c:\blah\blah"
agrace27 27-Jan-11 2:45am

Server Error

The network path was not found.
Indivara 27-Jan-11 3:54am
Did you solve this yet? Can you actually write to the path mentioned? Check the security settings on the shared folder (there are two places to set, share settings and security tab)

Is this with the easy method, or using impersonation? Log on to the server (where the app runs) and create a file in the shared folder, it will give you an idea of what is happening.

Oh and ignore the pressure to "finish it today", that only makes things worse.
Good luck...
agrace27 27-Jan-11 4:11am
i was extended my time by weekend.i done the network sharing and security options checked 2 box..which is the best method using impersonation or this method, i need the result kindly spare time and get the format to send to another pc/laptop using coding

how about FSO FileSystemObject CAN this copy the files to the destination..!!!
thank sir for giving prompt replies today.and also sorry for rushing!!!
Indivara 27-Jan-11 5:08am
Please see update 3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.1802120.2 | Last Updated 27 Jan 2011
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100