Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
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";
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 13-Dec-12 22:44pm
Edited 14-Dec-12 5:31am
v2
Rate this: bad
good
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?
  Permalink  
Rate this: bad
good
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.
  Permalink  
Comments
Member 7993229 at 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 at 14-Dec-12 11:47am
   
are you using file.copy to upload a single file?
Member 7993229 at 16-Dec-12 23:48pm
   
I'm trying to copy file using fileupload. but not working file.copy.
Rate this: bad
good
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
 
Thanks
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 358
1 Sergey Alexandrovich Kryukov 236
2 PhilLenoir 179
3 ChauhanAjay 151
4 ClimerChinna 150
0 Sergey Alexandrovich Kryukov 6,205
1 OriginalGriff 5,333
2 CPallini 2,473
3 Richard MacCutchan 1,617
4 Abhinav S 1,530


Advertise | Privacy | Mobile
Web01 | 2.8.140814.1 | Last Updated 14 Dec 2012
Copyright © CodeProject, 1999-2014
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