Click here to Skip to main content
13,097,192 members (66,168 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Dear All,

I'm getting problem while using below code. It is working on local mechin. But i uploaded remote location and using application it shown an error source path wrong. please find the below code.
string sourcePath = System.IO.Path.GetDirectoryName      (FileUpload1.PostedFile.FileName);
string targetPath = @"e:\\PODetails";
foreach (string sourceFilePath in Directory.GetFiles(@sourcePath))
   string fileName = Path.GetFileName(sourceFilePath);
   string destinationFilePath = Path.Combine(targetPath, fileName);
   File.Copy(sourceFilePath, destinationFilePath, true);

thank you.
Posted 13-Dec-12 22:44pm
Updated 14-Dec-12 5:31am
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

I would be tempted to check the following

1. Make sure that the remote machine has all the necessary permissions on the folders in question, if behind a firewall then check the settings also
2. Put a break point on the rountine, step through the code and make sure that the paths and filename are correct.
Member 7993229 14-Dec-12 11:43am
while i'm using file upload it will save single file into remote location. Please let me know how to copy bulk files on local to remote location.
Simon_Whale 14-Dec-12 11:47am
are you using file.copy to upload a single file?
Member 7993229 16-Dec-12 23:48pm
I'm trying to copy file using fileupload. but not working file.copy.
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

You can transfer the file from one server to another using FTP. This is the best way to transfer the files from one server to another. Using FTP you can dump more number of files.

Here are some links that can help you.

1. File Transfer Protocol (FTP) Client

2. Creating an FTP Server in C# - with IPv6 Support

3. FTP library

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

Solution 1

If you paste the contents of the sourcePath into your either your search line of start, or the run pop box, does it go to that path, or do you get an error there as well?

This is a good way to test if your path is valid on your sourcePath.

In addition, if you do this on the different machine/remote location, what happens?

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.170813.1 | Last Updated 14 Dec 2012
Copyright © CodeProject, 1999-2017
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