473,387 Members | 1,481 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

exception while copying a file to a network drive

I using the routine below to copy file to a network drive for a regular
backup process. Before calling this routine I using another function to check
the presence of the LAN connection and the server where the network drive
exists.
Although of this check I am sometimes getting an exception (in 5% of
times)saying "Could not find the U:\...\File.ext" or part of its path"
Although the network dirve is available and accessible by windows explorer
and the path is correct and
existing.
I would apreciate if some one can help troubleshooting this unexpected and
non understandable error.

Private Sub CopyFile(ByVal DstBasePath As String, ByVal SrcFileInfo As
FileInfo)
Try

Dim strDstFile As String = DstBasePath &
SrcFileInfo.FullName.Substring(2)

Dim DstFileInfo As New FileInfo(strDstFile)
If DstFileInfo.Directory.Exists = False Then
DstFileInfo.Directory.Create()
End If

Me.c_Status = String.Format("Copying {0}{1}To {2}", SrcFileInfo.Name,
vbCrLf, DstBasePath)

Me.c_Progress += 1

Me.c_FCD_Status.Invoke(SrcFileInfo.Name, Me.c_Progress, Me.c_Status,
True)

If DstFileInfo.Exists = False Then
SrcFileInfo.CopyTo(DstFileInfo.FullName)
ElseIf DstFileInfo.LastWriteTime <> SrcFileInfo.LastWriteTime Then
SrcFileInfo.CopyTo(DstFileInfo.FullName, True)
End If

Catch exIO As IOException

Catch ex As Exception

End Try

End Sub
Nov 21 '05 #1
2 2652
Hi

Looking through your question. Please tell me the answers to these
questions:

1) What is c_Status?
2) What is c_Progress? I think an Integer, but why are you using this if you
aren't using a recursive copy?
3) What is c_FCD_Status?
4) Is youe U:\ drive original or destination directory?
5) Have you tried an UNC path instead? Example: \\MyServer\MyPath etc.
6) Why are you creating a directory based on the filename?
7) Do you have to use FileInfo instead of a string for the srcFileInfo?
8) What file permissions are you using to copy a file over a network drive?

Awaiting your answers

Crouchie1998
BA (HONS) MCP MCSE
Nov 21 '05 #2
Thank you for your time looking at my question. Here's the answers:
1- c_Status is string e.g. "Copying xxx.yyy to c:\dstDir"
2- c_Progress is integer and it is used because the routine is recuresive
it's called with a loop in another routine.
3- c_FCD_Status is "Private c_FCD_Status As FileCopierStatus" where
FileCopierStatus is "Delegate Sub FileCopierStatus(ByVal FileName As String,
ByVal Progress As Integer, ByVal strStatus As String, ByVal Status As
Boolean)"
4- "U:\" is the distination directory and it's a mapped drive. On our
network there is a personal network drive for each user that is noly
accessible by the user only and mapped to "U:"
5- I have not try the UNC because the network drive is mapped on every
target machine as said the previous point.
6 & 7- are not clear form. What's the point?
8- I don't use a file permession to copy the file over the network, because
the user is having full control over his network personal drive "U:\" see
note: 4

Just to clarify When run this routin 100 times it gives the error message on
about 5 times out of the 100. So it's working fine but for know reason it
gives the exception "Couldn't find path U:\...\file.xxx" which means there's
a problem to access the destination file.

Also it could help if I mentioned this error is happening at the CopyTo
method of the FileInfo class, so you can forget about other lines in my code
because there a many other detatils that can not be given in such short note

Thanks in advance.

"Crouchie1998" wrote:
Hi

Looking through your question. Please tell me the answers to these
questions:

1) What is c_Status?
2) What is c_Progress? I think an Integer, but why are you using this if you
aren't using a recursive copy?
3) What is c_FCD_Status?
4) Is youe U:\ drive original or destination directory?
5) Have you tried an UNC path instead? Example: \\MyServer\MyPath etc.
6) Why are you creating a directory based on the filename?
7) Do you have to use FileInfo instead of a string for the srcFileInfo?
8) What file permissions are you using to copy a file over a network drive?

Awaiting your answers

Crouchie1998
BA (HONS) MCP MCSE

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Richard Jonas | last post by:
I've written a Windows Application in C#.net that runs in the background and silently archives files to a network drive (using the System.IO.File.Copy function). Sometimes, users may run this...
0
by: Oliver | last post by:
Hello, I may have posted in the wrong place, if so, feel free to move my post (just notify me where you put it via email or something) I’m having a problem with my program that I cant...
4
by: Boris | last post by:
I observe the following strange behavior of my application. Let say we have managed application MyApp.exe which depend on a few assemblies MyAssembly1.dll, MyAssembly2.dll and MyAssembly3.dll. The...
14
by: frostalicious | last post by:
Used VB.NET (on my client PC) to convert VB6 executable to .NET executable. Placed the .exe file on a network drive on my server. From client, ran .NET Wizards "Trust an Assembly" to make the...
8
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...
0
by: Alex Wieder | last post by:
Hi, I'm having a crazy error happening randomly on a console application that copies files from a Novell server to the local hard disk, zips them, and then ftp's them to yet another computer: ...
3
by: Jeries Shahin | last post by:
Hi I am trying to copy files from a folder on a Novel machine, the folder is in the UMC format (i cannot map a network drive for some business reasons). Upon copying, it fires an IOException...
8
by: jporter188 | last post by:
Hello, I am working on a project to manipulate XML files. All of the files, the code, and the output are on network drives. When I run my program I get an exception (see below). I tried giving...
0
by: SniperDemon | last post by:
Background: The Program runs a query on a SQL Database, then it takes the gathered information and outputs it into an excel document and saves it to a specified location. Problem: I currently...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...

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.