Reputation: 220
I am using a portal for uploading a data file in CSV format.when i am trying to upload a file,it is temporarily saved in C:\temp,and then it is bulk inserted into the DB server.
Issue:Data file is saving in the local system...not in the DB server temp.Because of this i am getting an error like C:\temp not found.
Mycode:
filePath = Path.Combine("C:\\temp", fileName);
Can anyone please help me to save my data in server temp.
Upvotes: 1
Views: 603
Reputation: 6999
If the server is in the same network you can use UNC pattern:
\\RemoteServer\SharedFolder\YourFiles
I had a similar case where I build the path myself:
var MachineName ="SomeServer";
var location = "Temp";
var fileName = "SomeFile.txt";
var path = string.Format(@"\\{0}\C$\{1}", MachineName, location);
var target = new FileInfo(Path.Combine(path, fileName));
Now you can use File.Copy
Upvotes: 1