Hi I would like to use File.Copy with UNC paths. I have seen this problem
reported by others as well. Can i use File.Copy with UNC paths. ie., i would
like to copy a file from one of the folder to a shared folder. eg.,
File.Copy(srcPath, "\\machinename\\folder)
This is giving an error "Could not find part of the path
\\machinename\\folder"
Is this feature supported? if yes please can anyone let me knwo how to
achieve it.
Thanks 3 5113
"Ganesha" <Ga*****@discussions.microsoft.comwrote in message
news:83**********************************@microsof t.com...
Hi I would like to use File.Copy with UNC paths. I have seen this problem
reported by others as well. Can i use File.Copy with UNC paths. ie., i
would
like to copy a file from one of the folder to a shared folder. eg.,
File.Copy(srcPath, "\\machinename\\folder)
This is giving an error "Could not find part of the path
\\machinename\\folder"
Is this feature supported? if yes please can anyone let me knwo how to
achieve it.
Thanks
Try escaping a double-backslash before machinename:
File.Copy(srcPath, "\\\\machinename\\folder");
- OR -
File.Copy(srcPath, @"\\machinename\folder");
I haven't tested to ensure that File.Copy can copy to a network folder via a
UNC path, so this may not be your solution, but as it stands by looking,
that could be the problem.
HTH,
Mythran
Hi Ganesha.
The problem is probably that you need to provide credentials to the current
thread before you can access the share.
if you run the program as a user who has access to the server share it
should work
in fact, if the current user has logged on with remote credentials
succesfully this session it should also work.
but if that's not an option you may need to drop into p/invoke to get
windows to manage the logon context for you.. and that's something I'd have
to look up myself.
Leon
"Mythran" <My*****@community.nospamwrote in message
news:33**********************************@microsof t.com...
>
"Ganesha" <Ga*****@discussions.microsoft.comwrote in message
news:83**********************************@microsof t.com...
>Hi I would like to use File.Copy with UNC paths. I have seen this problem reported by others as well. Can i use File.Copy with UNC paths. ie., i would like to copy a file from one of the folder to a shared folder. eg.,
File.Copy(srcPath, "\\machinename\\folder)
This is giving an error "Could not find part of the path \\machinename\\folder"
Is this feature supported? if yes please can anyone let me knwo how to achieve it.
Thanks
Try escaping a double-backslash before machinename:
File.Copy(srcPath, "\\\\machinename\\folder");
- OR -
File.Copy(srcPath, @"\\machinename\folder");
I haven't tested to ensure that File.Copy can copy to a network folder via
a UNC path, so this may not be your solution, but as it stands by looking,
that could be the problem.
HTH,
Mythran
I have an impersonation class on my blog which you call a function passing
the impersonation info (doman, username, password) and it raises an event in
which you can do the work while impersonated. When the event handler
completes, it undoes the impersonation. Its a handy tool to stop you having
to look that stuff up and do the Dll imports every time.
Let me know what you think.
--
Ciaran O''Donnell http://wannabedeveloper.spaces.live.com
"Leon Jollans" wrote:
Hi Ganesha.
The problem is probably that you need to provide credentials to the current
thread before you can access the share.
if you run the program as a user who has access to the server share it
should work
in fact, if the current user has logged on with remote credentials
succesfully this session it should also work.
but if that's not an option you may need to drop into p/invoke to get
windows to manage the logon context for you.. and that's something I'd have
to look up myself.
Leon
"Mythran" <My*****@community.nospamwrote in message
news:33**********************************@microsof t.com...
"Ganesha" <Ga*****@discussions.microsoft.comwrote in message
news:83**********************************@microsof t.com...
Hi I would like to use File.Copy with UNC paths. I have seen this problem
reported by others as well. Can i use File.Copy with UNC paths. ie., i
would
like to copy a file from one of the folder to a shared folder. eg.,
File.Copy(srcPath, "\\machinename\\folder)
This is giving an error "Could not find part of the path
\\machinename\\folder"
Is this feature supported? if yes please can anyone let me knwo how to
achieve it.
Thanks
Try escaping a double-backslash before machinename:
File.Copy(srcPath, "\\\\machinename\\folder");
- OR -
File.Copy(srcPath, @"\\machinename\folder");
I haven't tested to ensure that File.Copy can copy to a network folder via
a UNC path, so this may not be your solution, but as it stands by looking,
that could be the problem.
HTH,
Mythran This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: BoonHead, The Lost Philosopher |
last post by:
I think the .NET framework is great!
It's nice, clean and logical; in contradiction to the old Microsoft.
It only saddens me that the new Microsoft still doesn't under stand there own...
|
by: SeanR |
last post by:
I have a function to copare two files. It will first copy the original file
form a different server to a local temp path and then compare that version to
a version that has been restored form tape....
|
by: RitaG |
last post by:
Hi.
In a VB.Net program I use File.Copy to copy some zipped (and text) files
from one server to another. I'm required by management to do a file compare
after the copy has completed.
Is the...
|
by: DraguVaso |
last post by:
Hi,
I need a SECURE way to copy parts of a file. I'm having files which contains
a whole bunch of records. In one 'fysical' file I'm having one or more
logical files.
What I need to do is to...
|
by: luis molina Micasoft |
last post by:
it seems that when i do file.copy the svchost.exe is hanged, i mean if i make
40 threads of file.copy , 40 copys of files at same time the system is going
down and stop responding, this is when i'm...
| |
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...
|
by: Rachel McConnell |
last post by:
Hi,
I am trying to import data using COPY, from a file containing thirty or
so COPY commands each with 0 or more rows of data. Reason, I have a
small data set I want to include into a database...
|
by: maheshkadam |
last post by:
Hi friends
I am new to perl so please guide me.
I have one application which created backup log file every day.But it appends that file so you can see logs for different day in one file only.
...
|
by: =?Utf-8?B?UmFkZW5rb19aZWM=?= |
last post by:
I am using standard File.Copy(source,dest,true) method in C# and I have
problem with copying large number of files.
Here is my code:
foreach (FileInfo file in files)
{...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 ...
| |
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...
| |