I'm trying to delete off a 0-byte file that gets created after trying to
download from a bad URL, but I'm getting an IOException that says that it's
being used. I also noticed an InvalidOperationException before the
IOException in the debug output, but I can't seem to try/catch where that
comes up. After stripping off excess code from my .NET 2.0 Windows Forms
app, I have a button, a BackgroundWorker, and a WebClient-inheriting class
(Downloader). What am I doing wrong here?
My code looks like this:
*** Form1 class variables ***
bool myIsDownloading;
*** Form1::button1_Click ***
button1->Enabled = false;
backgroundWorker1->RunWorkerAsync();
*** Form1::backgroundWorker1_DoWork ***
Downloader^ dlr = gcnew Downloader(worker);
String^ filename = "C:\\test.txt";
dlr->DownloadFileAsync(gcnew Uri("crap", UriKind::Relative), filename);
myIsDownloading = true;
while (myIsDownloading)
{
Threading::Thread::Sleep(200);
}
try
{
File::Delete(filename);
}
catch (IOException^ e)
{
// "The process cannot access the file 'C:\\test.txt'
// because it is being used by another process."
// Huh?
MessageBox::Show(e->Message);
}
worker->ReportProgress(100);
*** Form1::backgroundWorker1_ProgressChanged ***
if (e->ProgressPercentage == 50)
{
myIsDownloading = false;
}
else if (e->ProgressPercentage == 100)
{
button1->Enabled = true;
}
*** Downloader::Downloader(BackgroundWorker^ bw) ***
myBackgroundWorker = bw;
*** Downloader::OnDownloadFileCompleted ***
myBackgroundWorker->ReportProgress(50); 4 1156
> I'm trying to delete off a 0-byte file that gets created after trying to download from a bad URL, but I'm getting an IOException that says that
it's being used. I also noticed an InvalidOperationException before the IOException in the debug output, but I can't seem to try/catch where that comes up.
You can configure debugger to break on exceptions (Debug/Exception). Say C++
and CLR exceptions. This way you will now where InvalidOperationException
comes from.
After stripping off excess code from my .NET 2.0 Windows Forms app, I have a button, a BackgroundWorker, and a WebClient-inheriting class (Downloader). What am I doing wrong here?
--
Vladimir Nesterovsky
e-mail: vl******@nesterovsky-bros.com
home: http://www.nesterovsky-bros.com
Thanks, that helped me track down the problem. I used a relative Uri for my
test on the DownloadFileAsync method without setting the BaseAddress
property for the WebClient. But why doesn't a try/catch block around that
call catch that exception?
"Vladimir Nesterovsky" <vl******@nesterovsky-bros.com> wrote in message
news:OS**************@tk2msftngp13.phx.gbl... I'm trying to delete off a 0-byte file that gets created after trying to download from a bad URL, but I'm getting an IOException that says that it's being used. I also noticed an InvalidOperationException before the IOException in the debug output, but I can't seem to try/catch where that comes up.
You can configure debugger to break on exceptions (Debug/Exception). Say C++ and CLR exceptions. This way you will now where InvalidOperationException comes from.
After stripping off excess code from my .NET 2.0 Windows Forms app, I have a button, a BackgroundWorker, and a WebClient-inheriting class (Downloader). What am I doing wrong here?
-- Vladimir Nesterovsky e-mail: vl******@nesterovsky-bros.com home: http://www.nesterovsky-bros.com
On Sat, 25 Jun 2005 00:14:57 -0700, "James Park"
<jp**********@SpaMMEhotmail.com> wrote: Thanks, that helped me track down the problem. I used a relative Uri for my test on the DownloadFileAsync method without setting the BaseAddress property for the WebClient. But why doesn't a try/catch block around that call catch that exception?
Don't know if it is exactly the answer to your question, but
exceptions can only be caught in the thread from which they originate.
(For example, ActiveMovie exceptions cannot usually be caught, since
AM usually starts multiple threads.)
"Vladimir Nesterovsky" <vl******@nesterovsky-bros.com> wrote in message news:OS**************@tk2msftngp13.phx.gbl... I'm trying to delete off a 0-byte file that gets created after trying to download from a bad URL, but I'm getting an IOException that says that it's being used. I also noticed an InvalidOperationException before the IOException in the debug output, but I can't seem to try/catch where that comes up.
You can configure debugger to break on exceptions (Debug/Exception). Say C++ and CLR exceptions. This way you will now where InvalidOperationException comes from.
After stripping off excess code from my .NET 2.0 Windows Forms app, I have a button, a BackgroundWorker, and a WebClient-inheriting class (Downloader). What am I doing wrong here?
-- Vladimir Nesterovsky e-mail: vl******@nesterovsky-bros.com home: http://www.nesterovsky-bros.com
--
Phillip Crews aka Severian
Microsoft MVP, Windows SDK
Posting email address is real, but please post replies on the newsgroup.
Ah, that makes sense. Thanks.
"Severian [MVP]" <se******@chlamydia-is-not-a-flower.com> wrote in message
news:3r********************************@4ax.com... On Sat, 25 Jun 2005 00:14:57 -0700, "James Park" <jp**********@SpaMMEhotmail.com> wrote:
Thanks, that helped me track down the problem. I used a relative Uri for my test on the DownloadFileAsync method without setting the BaseAddress property for the WebClient. But why doesn't a try/catch block around that call catch that exception?
Don't know if it is exactly the answer to your question, but exceptions can only be caught in the thread from which they originate. (For example, ActiveMovie exceptions cannot usually be caught, since AM usually starts multiple threads.)
"Vladimir Nesterovsky" <vl******@nesterovsky-bros.com> wrote in message news:OS**************@tk2msftngp13.phx.gbl... I'm trying to delete off a 0-byte file that gets created after trying to download from a bad URL, but I'm getting an IOException that says that it's being used. I also noticed an InvalidOperationException before the IOException in the debug output, but I can't seem to try/catch where that comes up.
You can configure debugger to break on exceptions (Debug/Exception). Say C++ and CLR exceptions. This way you will now where InvalidOperationException comes from.
After stripping off excess code from my .NET 2.0 Windows Forms app, I have a button, a BackgroundWorker, and a WebClient-inheriting class (Downloader). What am I doing wrong here?
-- Vladimir Nesterovsky e-mail: vl******@nesterovsky-bros.com home: http://www.nesterovsky-bros.com
-- Phillip Crews aka Severian Microsoft MVP, Windows SDK Posting email address is real, but please post replies on the newsgroup. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: MHenry |
last post by:
Hi,
We were going merrily along for 6 years using this database to record
all client checks that came into our office, including information
about what the checks were for.
Suddenly, network...
|
by: Jeff |
last post by:
Hello everybody,
I just have a little problem, and I just can't figure out what it is:
$ cat test.c
#include <stdio.h>
int main (void)
{
char* s = "CAT";
|
by: Skybuck Flying |
last post by:
Sometime ago on the comp.lang.c, I saw a teacher's post asking why C
compilers produce so many error messages as soon as a closing bracket is
missing. The response was simply because the compiler...
|
by: yezi |
last post by:
HI, ALL:
I can not figure out the problem with compiling.
the message is "
/tmp/ccAxyQSj.o(.text+0x275): In function `main':
: undefined reference to `sqrt'
collect2: ld returned 1 exit...
|
by: ken |
last post by:
Hello,
I can't figure out how to solve this problem. I modified the timer
example given in the help section. It increments a count every 3
millisecond in order to simulate a tank being filled with...
| |
by: Brian Blais |
last post by:
Hello,
I have an odd kind of Heisenbug in what looks like a pretty simple program. The
program is a progress bar code I got at the Python Cookbook:
...
|
by: joey.powell |
last post by:
I am using VS2005 for a windows forms application. I need to be able to
use a worker thread function to offload some processing from the UI
thread. The worker thread will need access to a...
|
by: Steve |
last post by:
I have a gridview which uses an objectdatasource for its select and
delete.
The delete command uses the function below. The delete itself works but
the extra logic which requires parameters...
|
by: Tony Girgenti |
last post by:
Hello.
I'm developing and testing a web application using VS.NET 2003, VB, .NET
Framework 1.1.4322, ASP.NET 1.1.4322 and IIS5.1 on a WIN XP Pro, SP2
computer. I'm using a web form.
For a...
|
by: Frank |
last post by:
Hi,
I use rpy to plot functions and have the following problem. When I
execute the following code line by line (start python and then execute
line by line) the resulting figure looks as it...
|
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: 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: 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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
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: 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...
| |