473,748 Members | 2,398 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

To search a file and to copy it from server

7 New Member
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\\serv erfolde\\folder \\ but it is not working.
My code is
searchfolder="y :\\Template\\el se";
destination ="D:\\Princy\\M y Documents\\proj ect\\";
string source=searchfo lder+"\\"+"mod5 01_"+filetosear ch+".3d";
string target=destinat ion+"mod501-"+filetosearch+ ".3d";
string[] files = Directory.GetFi les(searchfolde r, "mod501_"+filet osearch+".3d");
//string[] files = Directory.GetFi les(searchfolde r, filetosearch+"* ");
if(files.Length ==1)
{
foreach (string dir in files)
{
lblcnt.Text="Se lected File: "+ dir;
string[] search = Directory.GetFi les(destination ,"mod501-"+filetosearch+ ".3d");
if(search.Lengt h>0)
{
lblcnt.Visible= true;
lblcnt.Text="Fi le already exist";
}
else
{
File.Copy(sourc e,target);
lblcnt.Visible= true;
lblcnt.Text="Fi le copied";
}
}

what to give insted of
searchfolder="y :\\Template\\el se";

If am using
searchfolder="@ books\\template \\Template\\els e";
am geting error:
System.IO.Direc toryNotFoundExc eption:Could not find a part of the "@books\templat e\Template\els" .
Otherwise its working perfectly.
Sep 17 '07 #1
2 1690
princymg
7 New Member
file.copy(sourc e.target)
server shhould be
string source="\\\\ser ver\\folde\\";
Sep 18 '07 #2
Plater
7,872 Recognized Expert Expert
well in C# if you put an @ before a string everything is literals so a
string mystr=@"\\serve r\myshare\file. txt";
will actually BE \\server\myshar e\file.txt

But if you can access the shares in that manor from say a Start->Run box, then you should be able to in code. The only problem might be log-in credentials versus running user credentials?
(ie your program might be trying to "log in" to that directory with a dis-allowed ser of credentials)
Sep 18 '07 #3

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

Similar topics

1
2889
by: Luke Dalessandro | last post by:
I have an application where there is a primary XML data file. I'll use the following as an example: <data> <item id="a"> <name>A</name> <price>$10</price> </item> <item id="b"> <name>B</name>
2
3772
by: Stephen Witter | last post by:
I had previously posted this on the security ng, but haven't had a hit so I was wondering if someone here would be willing to take a stab. I am trying to copy a file to a network drive. I can do it on the web server but not from a client. Here is the code: Dim impersonationContext As System.Security.Principal.WindowsImpersonationContext Dim currentWindowsIdentity As System.Security.Principal.WindowsIdentity currentWindowsIdentity...
8
9759
by: Sarah | last post by:
I need to access some data on a server. I can access it directly using UNC (i.e. \\ComputerName\ShareName\Path\FileName) or using a mapped network drive resource (S:\Path\FileName). Here is my problem: my vb.net program has problems with UNC. If the UNC server is restarted or goes off-line, my VB.net program crashes. The code for UNC access to the file is included below and is put in the tick event of a form timer control running every...
9
2415
by: CGW | last post by:
I asked the question yesterday, but know better how to ask it, today: I'm trying to use the File.Copy method to copy a file from a client to server (.Net web app under IIS ). It looks to me that when I give a path like @"C:\holdfiles\myfile.txt" it looks on the server C drive. How do I pull from the client? Do I need a different class and/or method? Filestream? -- Thanks,
0
4236
by: Chung Leong | last post by:
Here's a short tutorial on how to the OLE-DB extension to access Windows Indexing Service. Impress your office-mates with a powerful full-text search feature on your intranet. It's easier than you think. First, download and install the extension (http://sourceforge.net/project/showfiles.php?group_id=171247&package_id=198554). Simply unzip the file and copy the correct version of php_oledb.dll into the PHP extensions folder. Then add the...
8
2605
by: rempit | last post by:
Hye all..I'm Newbie.. I'm using asp.net..This code below I put in .aspx file..And become like that.. I want to make something like "WHEN USER PUT SOMETHING IN TEXTBOX AND CLICK THE BUTTON SEARCH..THE RESULT COMEOUT IN NEW ' div '.. I want to apply to my website..Using AJAX code.. I just copy the code from http://www.w3schools.com/ajax/ajax_database.asp. Help me please..
2
1972
by: princymg | last post by:
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>...
9
15148
by: fniles | last post by:
I would like to copy a table(s) from SQL Server 2005 to a CVS file and vice versa. I was thinking to use the BCP command line utility, but I have a few questions: 1. The machine where I am going to run BCP utility does not have SQL Server installed, so BCP.exe and its underlying DLLs are not there. I copied BCP.EXE, then it tells me that it expects sqlncli.dll. After I copied that DLL, it now says "Unable to load BCP resource DLL. BCP...
1
1624
by: mravik | last post by:
Hi All, I have different subsystems in my application, if one is down it will through some error message in log file. I have a collection of error messages in another file and I want to check each message against a log file. my application is running on tomcat and log file will continuously appended by the server even there are no requests for server. My requirement is when I hit the server with a request, I want to capture the log of my...
0
8830
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9247
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8243
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6074
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3313
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2783
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.