tripps Posted September 17, 2003 Posted September 17, 2003 My requirement is to open a file for my web user, when he clicks on a button. Problem is that the physical location of the file is not on the Web Server but some other machine. For Ex. The file name is <MyFile.txt> this file is lying in a shared folder named <MySharedFolder> on the machine named <MyMachine> I use following code to open the file. const string QC = "\\"; strFileUrl = QC + QC + "MyMachine" + QC + "MySharedFolder" + QC +"MyFile"; //Above code populates string variable strFileUrl with the value "\\MyMachine\MySharedFolder\MyFile.txt" Server.Transfer(strFileUrl); This however does not work. It throws following error. System.ArgumentException: Invalid path for MapPath '\\MyMachine\MySharedFolder\MyFile.txt'. A virtual path is expected. So, basically Server.Transfer method requires the virtual path. Pl. help me...I am stuck up. Many Thanks !!! Regards tripps Quote
bungpeng Posted September 17, 2003 Posted September 17, 2003 You can copy the file from that machine to Web server first (use ASP.NET server process), then only use Server.Transfer to client Quote
Brijesh81 Posted September 18, 2003 Posted September 18, 2003 Thanks a lot bungpeng, could u please also help me in writing code to use the ASP.Net Server process to copy the files to the web server. Thanks a lot. Regards Quote
bungpeng Posted September 18, 2003 Posted September 18, 2003 Try this: Dim SourceFile, DestinationFile As String SourceFile = "[source location]" ' Define source file name. DestinationFile = "[Destination location]" ' Define target file name. FileCopy(SourceFile, DestinationFile) ' Copy source to target. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.