473,394 Members | 1,951 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,394 software developers and data experts.

File Move & Delete?

A Form has a FileUpload, 2 Buttons & a TextBox web server controls.
Using the FileUpload control, I want to give users the provision to
move & delete files that DO NOT exist in C:\Inetpub\wwwroot (i.e. the
root directory). This is the code:

<script runat="server">
Sub MoveFile(ByVal obj As Object, ByVal ea As EventArgs)
File.Move(fudFileSource.FileName, txtFileDest.Text)
'File.Move("F:\4.jpg", "C:\4.jpg")
End Sub

Sub DeleteFile(ByVal obj As Object, ByVal ea As EventArgs)
File.Delete(fudFileSource.FileName)
'File.Delete("F:\4.jpg")
End Sub
</script>

Now since the files do not exist in the root directory, I can't use
Server.MapPath but if I simply use fudFIleSource.FileName &
txtFileDest.Text to move a file from location to another location, then
the following error gets generated pointing to the File.Move() line:

Could not find file 'C:\WINNT\system32\4.jpg'.

& in case of the Delete method, the file doesn't get deleted. Is there
any way by which I can let users move & delete files that DO NOT exist
in the root directory?

Note that if I use the physical path of the files (as shown in the 2
commented lines in the code above), then both the Move & Delete methods
get executed successfully.

Thanks,

Arpan

Aug 30 '06 #1
3 3256
Hi

Why don't you try appending the physical drive name with the
fudFileSource.FileName, and then call the Move or Delete Method.

Something like

File.Move("F:\\" + fudFileSource.FileName, txtFileDest.Text), if you are
sure with the drive name.

Prem
"Arpan" wrote:
A Form has a FileUpload, 2 Buttons & a TextBox web server controls.
Using the FileUpload control, I want to give users the provision to
move & delete files that DO NOT exist in C:\Inetpub\wwwroot (i.e. the
root directory). This is the code:

<script runat="server">
Sub MoveFile(ByVal obj As Object, ByVal ea As EventArgs)
File.Move(fudFileSource.FileName, txtFileDest.Text)
'File.Move("F:\4.jpg", "C:\4.jpg")
End Sub

Sub DeleteFile(ByVal obj As Object, ByVal ea As EventArgs)
File.Delete(fudFileSource.FileName)
'File.Delete("F:\4.jpg")
End Sub
</script>

Now since the files do not exist in the root directory, I can't use
Server.MapPath but if I simply use fudFIleSource.FileName &
txtFileDest.Text to move a file from location to another location, then
the following error gets generated pointing to the File.Move() line:

Could not find file 'C:\WINNT\system32\4.jpg'.

& in case of the Delete method, the file doesn't get deleted. Is there
any way by which I can let users move & delete files that DO NOT exist
in the root directory?

Note that if I use the physical path of the files (as shown in the 2
commented lines in the code above), then both the Move & Delete methods
get executed successfully.

Thanks,

Arpan

Aug 30 '06 #2
File.Move("F:\\" + fudFileSource.FileName, txtFileDest.Text), if you are
sure with the drive name.
That's exactly where the problem lies. I am not at all sure what could
the drive name be. Even if I am sure, the source file may reside in any
directory/sub-directory. Even if I know the directory/sub-directory
where the file exists, the file name could be anything with any
extension.

The bottomline is the source file path & name could be any valid path &
name that exists in the hard drive.

Any other ideas?

Thanks,

Regards,

Arpan

Prem Kumar wrote:
Hi

Why don't you try appending the physical drive name with the
fudFileSource.FileName, and then call the Move or Delete Method.

Something like

File.Move("F:\\" + fudFileSource.FileName, txtFileDest.Text), if you are
sure with the drive name.

Prem
"Arpan" wrote:
A Form has a FileUpload, 2 Buttons & a TextBox web server controls.
Using the FileUpload control, I want to give users the provision to
move & delete files that DO NOT exist in C:\Inetpub\wwwroot (i.e. the
root directory). This is the code:

<script runat="server">
Sub MoveFile(ByVal obj As Object, ByVal ea As EventArgs)
File.Move(fudFileSource.FileName, txtFileDest.Text)
'File.Move("F:\4.jpg", "C:\4.jpg")
End Sub

Sub DeleteFile(ByVal obj As Object, ByVal ea As EventArgs)
File.Delete(fudFileSource.FileName)
'File.Delete("F:\4.jpg")
End Sub
</script>

Now since the files do not exist in the root directory, I can't use
Server.MapPath but if I simply use fudFIleSource.FileName &
txtFileDest.Text to move a file from location to another location, then
the following error gets generated pointing to the File.Move() line:

Could not find file 'C:\WINNT\system32\4.jpg'.

& in case of the Delete method, the file doesn't get deleted. Is there
any way by which I can let users move & delete files that DO NOT exist
in the root directory?

Note that if I use the physical path of the files (as shown in the 2
commented lines in the code above), then both the Move & Delete methods
get executed successfully.

Thanks,

Arpan
Aug 30 '06 #3
Arpan

I did it this way, probably you can give a try tooo.

..aspx
<form id="form1" runat="server">
<input id="File1" type="file" runat="server"/>
<asp:Button ID="Button1" runat="server" Text="Button" />
</form>

..aspx.cs
Response.Write(File1.Value); //This gives you the full path, not just
the filename.

Hope this helps
Prem

"Arpan" wrote:
File.Move("F:\\" + fudFileSource.FileName, txtFileDest.Text), if you are
sure with the drive name.

That's exactly where the problem lies. I am not at all sure what could
the drive name be. Even if I am sure, the source file may reside in any
directory/sub-directory. Even if I know the directory/sub-directory
where the file exists, the file name could be anything with any
extension.

The bottomline is the source file path & name could be any valid path &
name that exists in the hard drive.

Any other ideas?

Thanks,

Regards,

Arpan

Prem Kumar wrote:
Hi

Why don't you try appending the physical drive name with the
fudFileSource.FileName, and then call the Move or Delete Method.

Something like

File.Move("F:\\" + fudFileSource.FileName, txtFileDest.Text), if you are
sure with the drive name.

Prem
"Arpan" wrote:
A Form has a FileUpload, 2 Buttons & a TextBox web server controls.
Using the FileUpload control, I want to give users the provision to
move & delete files that DO NOT exist in C:\Inetpub\wwwroot (i.e. the
root directory). This is the code:
>
<script runat="server">
Sub MoveFile(ByVal obj As Object, ByVal ea As EventArgs)
File.Move(fudFileSource.FileName, txtFileDest.Text)
'File.Move("F:\4.jpg", "C:\4.jpg")
End Sub
>
Sub DeleteFile(ByVal obj As Object, ByVal ea As EventArgs)
File.Delete(fudFileSource.FileName)
'File.Delete("F:\4.jpg")
End Sub
</script>
>
Now since the files do not exist in the root directory, I can't use
Server.MapPath but if I simply use fudFIleSource.FileName &
txtFileDest.Text to move a file from location to another location, then
the following error gets generated pointing to the File.Move() line:
>
Could not find file 'C:\WINNT\system32\4.jpg'.
>
& in case of the Delete method, the file doesn't get deleted. Is there
any way by which I can let users move & delete files that DO NOT exist
in the root directory?
>
Note that if I use the physical path of the files (as shown in the 2
commented lines in the code above), then both the Move & Delete methods
get executed successfully.
>
Thanks,
>
Arpan
>
>

Aug 30 '06 #4

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

Similar topics

5
by: matt dittman | last post by:
I have created a windows service that reads emails from a drop directory and moves them to the appropriate mail folder every 15 seconds. I can move, rename and delete the files as needed, up...
3
by: Don Pasquale | last post by:
The following function intends to delete "numberoflines" lines from a text file, named "s" (string pointer) and pointed to by file pointer "fp", starting from line "line". Now, the function...
3
by: Daniel | last post by:
Is it possible to retain local file system read, write, delete access while impersonating for access to a remote drive in a different domain? I need to be able to move files from a local computer...
1
by: Mike Chan | last post by:
Is it possible to drop a file from the VB.Net Application to the "Desktop" or somewhere and start the copy file action? (I already know how to drop in the application, but no idea how to drop out)
1
by: Marco Zender | last post by:
Hello, i'm in real trouble and don't know how to handle it! May someone can give me a hint? Following problem: In my application you can drag&drop a file from the explorer. In my application...
1
by: Chris | last post by:
We had an application running on a server that had been working for months with no problem. Last night, without any known change to the server, it started to fail. We tried all kinds of...
1
by: Tim Failes | last post by:
This seems a trival question, but I cannot get it to work properly... Essentially my question is, how can I create a text file, and guarantee it is given the current date/time as the Creation Time?...
2
by: john_aspinall | last post by:
Here's the overview: Im building an eCommerce web site using ASP. It has an Access DB at the back end. Im receiving the Product info from a series of CSV files. Ive created a Table in Access...
2
by: macneed | last post by:
Can i lock a file in c#, that i can move it and del it, but other program don't have right to access(read) until i release it? i read fileshare.none, but can't delete it without close the...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
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...
0
tracyyun
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 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.