472,951 Members | 2,561 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Windows explorer program

im writing a c# console application that copies files chosen from the windows
explorer. I chose the files i want to copy and then from the (right key) menu
chose my program.
the program starts fine but passes an error that the file(s) are in use ny
another user. This other user must be the windows explorer. Any workarounds
to free the files from the windows explorer?
Jun 27 '08 #1
5 2288
Are you trying to copy files from Windows Explorer? I take it you have
created your own menu item to the Context Menu that Windows Explorer uses.
I'd be interested to learn how you did that!

Anyway, on to your problem: Are you creating a copy of the file before you
try to do anything else with it? What part of your program passes the error?
Is it the actual copy method? Are you using System.IO.File or something else?
Have you tried cloning the file?

You might need to show some code for us to help you better.

"Jape" wrote:
im writing a c# console application that copies files chosen from the windows
explorer. I chose the files i want to copy and then from the (right key) menu
chose my program.
the program starts fine but passes an error that the file(s) are in use ny
another user. This other user must be the windows explorer. Any workarounds
to free the files from the windows explorer?
Jun 27 '08 #2
I have added my application to the context menu of windows explorer.
I wrote a short windows program which inserted the menuitem into the
register (guess you could edit the register manually)
Then i right-click on the files i want to copy and choose my program from
the context menu.
I tried IO.File and IO.FileInfo but both give the same error message that
the file is in use by another process.
I also have a Windows version of the application in which i can use two
different ways of getting the files onto a ListBox from which i submit the
copy for each file: first by the OpenFileDialog and secondly by dragdrop the
files from windows explorer. The first way works fine but the second way
gives the same error as the console application. Even if i clse windows
explorer before the submitting the copy, the error is the same.

The copy code i simply:

FileInfo fi = new FileInfo(filein);
fi.CopyTo(fileout, true);

or with File it was:

File.Copy(filein, fileout, true);


"jp2msft" wrote:
Are you trying to copy files from Windows Explorer? I take it you have
created your own menu item to the Context Menu that Windows Explorer uses.
I'd be interested to learn how you did that!

Anyway, on to your problem: Are you creating a copy of the file before you
try to do anything else with it? What part of your program passes the error?
Is it the actual copy method? Are you using System.IO.File or something else?
Have you tried cloning the file?

You might need to show some code for us to help you better.

"Jape" wrote:
im writing a c# console application that copies files chosen from the windows
explorer. I chose the files i want to copy and then from the (right key) menu
chose my program.
the program starts fine but passes an error that the file(s) are in use ny
another user. This other user must be the windows explorer. Any workarounds
to free the files from the windows explorer?
Jun 27 '08 #3
Jape,

I know this sounds silly, but your filein and fileout *do* have separate
paths, don't they?

Otherwise, I don't know what to suggest.

Have you included your code in a try...catch to see what the exact error
message is? I'm guessing that error would be "the file(s) are in use by
another user" or something to that effect.

You could use the code below to find out exactly what type of error you are
getting. This should help you narrow it down.

try {
File.Copy(filein, @"C:\Temp\" + filein, true);
} catch (System.IO.DirectoryNotFoundException err) {
MessageBox.Show(err.Message);
} catch (System.ArgumentException err) {
MessageBox.Show(err.Message);
} catch (System.UnauthorizedAccessException err) {
MessageBox.Show(err.Message);
} catch (System.NotSupportedException err) {
MessageBox.Show(err.Message);
} catch (System.IO.IOException err) {
MessageBox.Show(err.Message);
} catch (System.IO.PathTooLongException err) {
MessageBox.Show(err.Message);
} catch (System.ArgumentNullException err) {
MessageBox.Show(err.Message);
} catch (System.IO.FileNotFoundException err) {
MessageBox.Show(err.Message);
}
"Jape" wrote:
I have added my application to the context menu of windows explorer.
I wrote a short windows program which inserted the menuitem into the
register (guess you could edit the register manually)
Then i right-click on the files i want to copy and choose my program from
the context menu.
I tried IO.File and IO.FileInfo but both give the same error message that
the file is in use by another process.
I also have a Windows version of the application in which i can use two
different ways of getting the files onto a ListBox from which i submit the
copy for each file: first by the OpenFileDialog and secondly by dragdrop the
files from windows explorer. The first way works fine but the second way
gives the same error as the console application. Even if i clse windows
explorer before the submitting the copy, the error is the same.

The copy code i simply:

FileInfo fi = new FileInfo(filein);
fi.CopyTo(fileout, true);

or with File it was:

File.Copy(filein, fileout, true);


"jp2msft" wrote:
Are you trying to copy files from Windows Explorer? I take it you have
created your own menu item to the Context Menu that Windows Explorer uses.
I'd be interested to learn how you did that!

Anyway, on to your problem: Are you creating a copy of the file before you
try to do anything else with it? What part of your program passes the error?
Is it the actual copy method? Are you using System.IO.File or something else?
Have you tried cloning the file?

You might need to show some code for us to help you better.

"Jape" wrote:
im writing a c# console application that copies files chosen from the windows
explorer. I chose the files i want to copy and then from the (right key) menu
chose my program.
the program starts fine but passes an error that the file(s) are in use ny
another user. This other user must be the windows explorer. Any workarounds
to free the files from the windows explorer?
Jun 27 '08 #4
In article <80**********************************@microsoft.co m>, Jape wrote:
Then i right-click on the files i want to copy and choose my program from*
the context menu.*
I tried IO.File and IO.FileInfo but both give the same error message that*
the file is in use by another process.
I also have a Windows version of the application in which i can use two*
different ways of getting the files onto a ListBox from which i submit the*
copy for each file: first by the OpenFileDialog and secondly by dragdrop the*
files from windows explorer.
I'm not sure what FileShare mode FileInfo and CopyTo use by default. If the
explorer keeps the (selected) file open, you will be denied access unless a
FileShare mode that allows the file to already be open by another process is
used. You may need to open (FileInfo.Open) the input file with a FileShare
including Read access.

Mike

Jun 27 '08 #5

I found out a new "feature" in the problem. The means of the application is
to copy files form a development server to seversl production servers. Our
main development server is a w2000 based server. We also have another
development-server which is a w2003 server.
From the w2003 server the copying works fine so it seems that the problem
exists only on the w2000 server. Unfotunately its our main dev-server and
wont be upgraded for some time to w2003 or w2008.
Oh, and the error message is: System.IO.IOException: The process cannot
access the file '\\SERVERX\jtest1\testi4.asp' because it is being used by
another process.

And this SERVERX is the w2000 server.

"Mike Blake-Knox" wrote:
In article <80**********************************@microsoft.co m>, Jape wrote:
Then i right-click on the files i want to copy and choose my program from
the context menu.
I tried IO.File and IO.FileInfo but both give the same error message that
the file is in use by another process.
I also have a Windows version of the application in which i can use two
different ways of getting the files onto a ListBox from which i submit the
copy for each file: first by the OpenFileDialog and secondly by dragdrop the
files from windows explorer.

I'm not sure what FileShare mode FileInfo and CopyTo use by default. If the
explorer keeps the (selected) file open, you will be denied access unless a
FileShare mode that allows the file to already be open by another process is
used. You may need to open (FileInfo.Open) the input file with a FileShare
including Read access.

Mike

Jun 27 '08 #6

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

Similar topics

0
by: Tom Dacon | last post by:
"Open .Net Command Window Here" context menu for Windows Explorer: The reg file described below adds a new menu item to Windows Explorer's context menu when you right-click over a folder (or the...
1
by: MAFDoit | last post by:
Newsgroup: In Windows explorer (Not internet explorer) when viewing .txt files the information displayed usually includes name, size, type, date modified, etc. It's also possible to display...
0
by: MAFDoit | last post by:
NEWSGROUP: This is a followup to the post below. The original post was helpful and I now know many ways to RETRIEVE information from Windows explorer, but I haven't yet found a way to INSERT or...
2
by: Simon Jefferies | last post by:
Hello, How do I perform a drag and drop from a list view control to windows explorer? I am looking to perform a file copy from files in my list view to the destination in the windows explorer...
0
by: Asif | last post by:
Hi all, I am working on an MDI application using VB.NET. Applications launches normally either from Program Files or Desktop shortcut but some times when it launches from Windows Explorer by...
2
by: =?Utf-8?B?ZGlncmVnYQ==?= | last post by:
After installing Microsoft Office 2007 + desktop search, Windows explorer began to give me all kinds of errors including a DR Watson, which I haven't seen since installing XP. I found a forum...
0
by: Shafiq | last post by:
Hi All, Based on the sample kbbar.net applicaation i have created a tool bar for windows explorer. Now i have to enable and disable few buttons based the user slects file in the explorer. For to...
0
by: philaphan80 | last post by:
I'm hoping someone can offer some guidance regarding a concept I have. I'm trying to perform the following within Windows Explorer: 1. Add an entry to the context menu which should be executed...
16
by: John | last post by:
I am looking for VBA code that will work with Access 2003 to enable dragging and dropping a file/folder name from Windows XP Explorer into an Access form's text box. This is a common functionality...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...

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.