Hi,
I'm trying to upload some files via a form, and I have managed so far to
save the files on the server in a temporary directory using:
HttpPostedFile. SaveAs(string filename);
This is a necessary stage as I need to perform some tests on the file
before allowing it to be saved to its final destination directory. The
files being uploaded contain data, so it's necessary to test the
integrity of the data after uploading it.
The problem now is that, after I have uploaded and tested the data, I
then want to move the file (or delete it if it was not valid) to the
data directory. I then receive the following error:
"The process cannot access the file because it is being used by
another process."
I have tried to find a method of closing the file that has been saved by
the above method, but I can't seem to find one. Any suggestions?
--
Dylan Parry http://webpageworkshop.co.uk -- FREE Web tutorials and references
Listening to: Rush - Cygnus X-1 Book II : Hemispheres 5 7053
Dylan Parry <us****@dylanpa rry.com> wrote: I'm trying to upload some files via a form, and I have managed so far to save the files on the server in a temporary directory using:
HttpPostedFile. SaveAs(string filename);
This is a necessary stage as I need to perform some tests on the file before allowing it to be saved to its final destination directory. The files being uploaded contain data, so it's necessary to test the integrity of the data after uploading it.
The problem now is that, after I have uploaded and tested the data, I then want to move the file (or delete it if it was not valid) to the data directory. I then receive the following error:
"The process cannot access the file because it is being used by another process."
I have tried to find a method of closing the file that has been saved by the above method, but I can't seem to find one. Any suggestions?
Reflector indicates that that method does indeed close the file. You
might consider copying the data out of the HttpPostedFile. InputStream
and testing that directly, followed by saving to its final location
directly.
-- Barry
Hi,
Are you closing the file after y ou finish working with it, are you using a
thread or something like that?
Apparently that is the error you are getting
Another possible source of error (not present here) is if you want to move
the file to a dir to which the user under the IIS is executing has no
permission, by default ASP.net run under anonymous_IIS , this use has a very
limited set of permissions.
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Dylan Parry" <us****@dylanpa rry.com> wrote in message
news:52******** ******@dylanpar ry.com... Hi,
I'm trying to upload some files via a form, and I have managed so far to save the files on the server in a temporary directory using:
HttpPostedFile. SaveAs(string filename);
This is a necessary stage as I need to perform some tests on the file before allowing it to be saved to its final destination directory. The files being uploaded contain data, so it's necessary to test the integrity of the data after uploading it.
The problem now is that, after I have uploaded and tested the data, I then want to move the file (or delete it if it was not valid) to the data directory. I then receive the following error:
"The process cannot access the file because it is being used by another process."
I have tried to find a method of closing the file that has been saved by the above method, but I can't seem to find one. Any suggestions?
-- Dylan Parry http://webpageworkshop.co.uk -- FREE Web tutorials and references
Listening to: Rush - Cygnus X-1 Book II : Hemispheres
Pondering the eternal question of "Hobnobs or Rich Tea?", Ignacio Machin
( .NET/ C# MVP ) finally proclaimed: Are you closing the file after y ou finish working with it, are you using a thread or something like that?
I think you might be on to something there. I will check to see whether
the checking process actually closes the files - I have a feeling that
it might not!
Thanks,
--
Dylan Parry http://webpageworkshop.co.uk -- FREE Web tutorials and references
Hi, The problem now is that, after I have uploaded and tested the data,
Reflector indicates that that method does indeed close the file. You might consider copying the data out of the HttpPostedFile. InputStream and testing that directly, followed by saving to its final location directly.
She did test the data form the file, this mean she opened/read and not quite
close it :)
OP: Can you post the code you are using?
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Pondering the eternal question of "Hobnobs or Rich Tea?", Ignacio Machin
( .NET/ C# MVP ) finally proclaimed: She did test the data form the file, this mean she opened/read and not quite close it :)
That's exactly what was happening... although I'm not sure who "she" is
:s
OP: Can you post the code you are using?
No need. I found that the method I was using to check the data (one that
I didn't write) wasn't closing the files on its own and needed me to
explicitly tell it to do so. As such it's working fine now!
Thanks,
--
Dylan Parry http://webpageworkshop.co.uk -- FREE Web tutorials and references This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Robert McGregor |
last post by:
Hi all,
I've got a Front End / Back End database that was working just fine.
One day i opened the FE to find that if I tried to open one of the
linked tables from the database window, nothing happened (hourglass
for about 2 seconds then nothing).
I tried relinking the tables and got the same response. (Access even
completely bombed out once with a Dr Watson failure).
|
by: mytfein |
last post by:
Hi Everyone,
Background:
Another department intends to ftp a .txt file from the mainframe, for me
to process.
The objective is to write a vb script that would be scheduled to run
daily to process this .txt file.
Goal:
I am working on a vba script to:
|
by: Ken Allen |
last post by:
I have enocuntered something wierd.
If I invoke an instance of the above dialog and elect to save the file in a
directory where a file of that name does not exist, then the return is
DialogResult.OK, but if I elect to save the file on top of a file with the
same name in the same directory, when I press the Save button I get a "do
you want to overwrite" dialog -- even if I press OK the SaveFileDialog
returns DialogResult.Cancel!
How...
|
by: Sobhan Vezzu |
last post by:
Hi All,
Using a webpage I am uploading the file onto webserver. First time
it works fine. If I use the same file from second time it throws an
error.
Error:
"The process cannot access the file "<FileName>" because it is being
used by another process."
|
by: fa_2064 |
last post by:
hi every body
when i run this code i receive this error! my "wwwroot" folder is
shared, but i don't know what it's reason is!!!
{"Access to the path
\"D:\\Inetpub\\wwwroot\\iranian\\images\\user_imgs\\Untitled-1.jpg\" is
denied." }
is there a way that the url be relative???
my code is:
| |
by: Paul |
last post by:
Hi I am using the HtmlInputFile control to upload a file from a client to a
server. I have a browse to find the file on the server but need to create
the path dynamically as to were it will go based on some dropdown boxes, one
for the year and one for the month. This line saves the file so I am trying
to get the month and year from the dropdown boxes and put them in the month
and year variables but this does not work,...
|
by: .nu |
last post by:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Name: Sleepy Hollow
# Author: .nu
import wx
import os
import sys
|
by: Don |
last post by:
QUESTIONS:
1. Has anyone figured out how to successfully install the Office 97
Pro Service Release 2 patch in Vista?
2. Has anyone successfully installed an Office 97 Pro CD (SR2
version) in Vista?
DETAILS:
My setup: Dell Inspiron notebook with Vista Business edition
My CD: Office 97 Professional (Service Release 1) Upgrade
|
by: andrescasta |
last post by:
Hello, i have a problem when i try to delete a file that i recently uploaded.
To upload, i used the FileUpload, when i receive the file, i save it in a directory inside the virtual application (ASPNET account have full control on it, ).
...
try
{
//Save the image
FileUpload1.PostedFile.SaveAs(savepath); <---This work OK.
FileUpload1.PostedFile.InputStream.Close();
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |