Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 150,062 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,747 people online right now. Registration is fast and FREE... Join Now!




file.copy exception

 
Closed TopicStart new topic

file.copy exception, cannot overwrite a file

RayAtCafeVittoria
4 Feb, 2008 - 01:20 PM
Post #1

New D.I.C Head
*

Joined: 17 Sep, 2007
Posts: 16


My Contributions
I don't understand why I am getting an error when I run this bit of code:


CODE

LabelName ="BITMAP.BMP" 'set elsewhere in the code
CopyTo = "\\Serveurwin\Fortune\LabelBitmaps\" & LabelName

Try
    File.Copy("C:\Temp\tmp001.bmp", CopyTo, True)
Catch ex As Exception
    MsgBox(ex.ToString, MsgBoxStyle.Exclamation)
End Try


It works fine for the first time, but if I try to overwrite the previous file I get an error saying that the file is in use by another process and cannot be copied. I tried it with the directory mapped to a drive letter with the same result. However if I set the destination to a local directory there is no problem.

This would usually indicate a problem with permissions, but if that was the case why can I create the file once then not be able to overwrite it? I have checked the settings on the server. The directory is supposed to be full access. I can overwrite the updated file by dragging it from my local drive to the server, so it should not be a permissions problem.

Just to be clear on what I am doing here.
The .bmp is generated on my local drive then when I hit save, the temporary bitmap file is copied to the server with an autogenerated name. When I modify then save again it is supposed to overwrite the previous file with the newly generated bitmap.

Any ideas?

RC
User is offlineProfile CardPM
+Quote Post

RayAtCafeVittoria
RE: File.copy Exception
4 Feb, 2008 - 01:55 PM
Post #2

New D.I.C Head
*

Joined: 17 Sep, 2007
Posts: 16


My Contributions
blush.gif Forget it stupid.gif

I have been running this project for a while in debug mode, but I hadn't rebuilt it for a few hours... just saved changes.

Chose rebuild from the build menu.... and the problem disappeared.

RC


User is offlineProfile CardPM
+Quote Post

Closed TopicStart new topic
Time is now: 1/8/09 10:39PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month