By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,978 Members | 1,373 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,978 IT Pros & Developers. It's quick & easy.

To search a file and copy it to server

P: 7
I want to search a file from server and want to copy it to the local disk.
how it is done? This is working if the file is in my hard disk itself.But not when it comes to server. If i map the server i can search.like y:\\serverfolde\\folder am tring to make an exe. different people will map to different drive. so i cant give like that.should give like @\\server\\serverfolde\\folder\\ but it is not working.
My code is<code>
searchfolder="y:\\Template\\else";
destination ="D:\\Princy\\My Documents\\project\\";
string source=searchfolder+"\\"+"mod501_"+filetosearch+". 3d";
string target=destination+"mod501-"+filetosearch+".3d";
string[] files = Directory.GetFiles(searchfolder, "mod501_"+filetosearch+".3d");
//string[] files = Directory.GetFiles(searchfolder, filetosearch+"*");
if(files.Length==1)
{
foreach (string dir in files)
{
lblcnt.Text="Selected File: "+ dir;
string[] search = Directory.GetFiles(destination,"mod501-"+filetosearch+".3d");
if(search.Length>0)
{
lblcnt.Visible=true;
lblcnt.Text="File already exist";
}
else
{
File.Copy(source,target);
lblcnt.Visible=true;
lblcnt.Text="File copied";
}
}
</code>
what to give insted of
searchfolder="y:\\Template\\else";

If am using
searchfolder="@books\\template\\Template\\else";
am geting error:
System.IO.DirectoryNotFoundException:Could not find a part of the "@books\template\Template\els".
Otherwise its working perfectly.
Sep 17 '07 #1
Share this Question
Share on Google+
2 Replies


epots9
Expert 100+
P: 1,351
i'm assuming this is C#, please post in the .Net Forums where the resident experts can better assist you.
Sep 17 '07 #2

P: 7
File.copy(source,target);
Sep 18 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.