How to upload a file to a Samba share using ASP.NET application on Windows 2003 Server?
Posted on 2004-11-09
I have to upload a file to a Samba share using the ASP.NET application on Windows 2003 Server.
If I needed just to upload a file to save it on the server's folder, I would just use either the PostedFile.SaveAs("finename") or
HttpFileCollection MyFileCollection = Request.Files and then MyFileCollection[index].SaveAs("FileName")
- both ways worked OK for the server's folder. But I can't provide a samba share description in place of the file name because the user name and password are needed for the share, and the format of these method does not allow it.
How should I do it? My idea was to run a batch file to map a samba share and then upload the file to that map.
It worked OK on my Windows XP server, but it does not work on the Windows 2003 Server. (the batch file contained just one statement: "Net use Y: \\bosfhristest51\hrimports <password> /USER:<domainname>\<username>"
However the Windows 2003 Server throws "Access is denied" exception when I try to execute ANY batch file, even the simpliest one. (I execute the batch file using the following code:
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.UseShellExecute = false;
Again, this works on a Windows XP server but does not work on a Windows 2003 Server.
I am asking EITHER for another way to upload a file to a samba share OR for detailed and specific instructions how I should set the Windows 2003 Server to execute a batch file. So far my attempts to do it were unsuccessful.
How can I do it ???
Thank you in advance for your help !