Jump to content
Xtreme .Net Talk

Pl. Help :: Open file lying on different machine


Recommended Posts

Posted

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

Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...