473,387 Members | 1,520 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.

File Locking Question

I'm writing a WinForms app that copies files to Pocket PC using the RAPI
'CopyFileToDevice' method. If there are no interruptions then everything
works perfectly.

But in testing, I've deliberately disconnected the Pocket PC to see what
happens.

Upon reconnection I get an error that the source file is being used by
another process - in other words, the file is locked.

Since I know the previous process has concluded, is there a way for me to
forcibly unlock the file?

--
Robert W.
Vancouver, BC
www.mwtech.com

Nov 17 '05 #1
2 4028
AFAIK, there's no easy way around this - pulling the cable while syncing
sucks - BAD. Let me look around for you but typically it's going to be a
mess if it happens.

W.G. Ryan MVP
Windows Embedded
"Robert W." <Ro*****@discussions.microsoft.com> wrote in message
news:16**********************************@microsof t.com...
I'm writing a WinForms app that copies files to Pocket PC using the RAPI
'CopyFileToDevice' method. If there are no interruptions then everything
works perfectly.

But in testing, I've deliberately disconnected the Pocket PC to see what
happens.

Upon reconnection I get an error that the source file is being used by
another process - in other words, the file is locked.

Since I know the previous process has concluded, is there a way for me to
forcibly unlock the file?

--
Robert W.
Vancouver, BC
www.mwtech.com

Nov 17 '05 #2
Here's one approach I'm considering. What do you think:

When I startup the WinForms app I can ensure that there's a temporary
subfolder, like: C:\Temp\AppName I will try to erase all files in it.

When it's time to copy a file to a mobile device I can first use File.Copy
to copy the source file (which seems to work regardless if there's a lock)
into this folder. And if the file already exists, perhaps from a previous
lock, then I'd just add a numeric digit to it until I found a free filename -
like "Filename1.ext", "Filename2.ext", etc.

And then this copy, which I'll know is not locked, I can copy to the mobile
device.

Comments appreciated.

--
Robert W.
Vancouver, BC
www.mwtech.com

"W.G. Ryan eMVP" wrote:
AFAIK, there's no easy way around this - pulling the cable while syncing
sucks - BAD. Let me look around for you but typically it's going to be a
mess if it happens.

W.G. Ryan MVP
Windows Embedded
"Robert W." <Ro*****@discussions.microsoft.com> wrote in message
news:16**********************************@microsof t.com...
I'm writing a WinForms app that copies files to Pocket PC using the RAPI
'CopyFileToDevice' method. If there are no interruptions then everything
works perfectly.

But in testing, I've deliberately disconnected the Pocket PC to see what
happens.

Upon reconnection I get an error that the source file is being used by
another process - in other words, the file is locked.

Since I know the previous process has concluded, is there a way for me to
forcibly unlock the file?

--
Robert W.
Vancouver, BC
www.mwtech.com


Nov 17 '05 #3

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

Similar topics

5
by: Micha³ Wo¼niak | last post by:
Hi again The Question of Logs, part II. :) What are the advantages/disadvantages of using syslog() to do the logging rather than writing the logs with fopen(), fwrite() and fclose()? What...
2
by: Geoffrey | last post by:
We have developed a python class that can read data files created from another application. These target files are C-ISAM files used for accounting applications so the "primary" application may be...
2
by: Kamus of Kadizhar | last post by:
Thanks to Robert Brewer, I got enough insight into logging to make it work.... Now I have another issue: file locking. Sorry if this is a very basic question, but I can't find a handy reference...
4
by: Alex | last post by:
Is there any way to link a table to a front end for reference only (no requirement to edit data) so that the LDB file is not created. I use a number of tables for reference and do not need to edit...
2
by: Corne' Cornelius | last post by:
Hi, When you open a file for writing/appending with open() or fopen(), and you have multiple applications that might want to write to the same file at the same time, could that cause weirdness...
3
by: noridotjabi | last post by:
Say I'm writting a program. In this program for some reason I need to store data somewere were I will be able to access it again. I don't want to store it in a file because then it could be...
13
by: George | last post by:
Hi, I am re-writing part of my application using C#. This application starts another process which execute a "legacy" program. This legacy program writes to a log file and before it ends, it...
17
by: Peter Duniho | last post by:
I searched using Google, on the web and in the newsgroups, and found nothing on this topic. Hopefully that means I just don't understand what I'm supposed to be doing here. :) The problem: ...
15
by: Matt Brandt | last post by:
I am trying to get multiple threads to lock specific regions of a file. However, since each thread has the same PID, it appears that a lock by one thread does not block another thread from the same...
2
by: Sparky | last post by:
Hello! I am writing some software that will have many users accessing the same file resource at once for reading purposes only. I am programming on (Ubuntu) Linux and my question is in Windows, can...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
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,...
0
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...

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.