Click here to Skip to main content
15,904,348 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.
C#
string sourcePath = System.IO.Path.GetDirectoryName      (FileUpload1.PostedFile.FileName);
string targetPath = @"e:\\PODetails";
sourcePath.GetHashCode();
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
Updated 14-Dec-12 5:31am
v2

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.
 
Share this answer
 
Comments
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.
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

Thanks
 
Share this answer
 
v2
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?
 
Share this answer
 

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