Click here to Skip to main content
15,881,173 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
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 = "\\192.168.1.111\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
Updated 26-Jan-11 17:06pm
v3
Comments
Indivara 26-Jan-11 23:04pm    
Fixed language a bit...

1 solution

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 \\192.168.1.111\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 \\192.168.1.xxx\websave
  • Grant full access to the Everyone group to the folder share
  • fileUpload.PostedFile.SaveAs(@"\\192.168.1.xxx\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 --
http://geek.hubkey.com/2008/02/impersonating-built-in-service-account.html[^]

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.
 
Share this answer
 
v5
Comments
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 ip-192.XXX.x.xxx
\\192.168.1.111\c:\dump\xxx.dmp

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 ip-192.XXX.x.xxx
\\192.168.1.111\c:\dump\xxx.dmp

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    
FileUpload1.PostedFile.SaveAs("\\192.168.1.102\c:\tdata\GN_APPACCESS.DMP")

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("\\192.168.1.102\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

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900