Hi, i would like to move a selected files to a folder using vb.net.
I currently have this code
If File.Exists("C: \Documents and Settings\055949 x\transfer\text .txt") And Not File.Exists("C: \Documents and Settings\055949 x\transfer\text .txt") Then
File.Move("C:\D ocuments and Settings\055949 x\transfer\text .txt", "C:\Documen ts and Settings\055949 x\Desktop\AES file\transfer\t ext.txt")
Label1.Text = ("File moved!")
Else
Label1.Text = ("File does not exist")
End If
How to i make it sure that i will be able to move different files without having to write the full directory of the file? I need to move the files that had been display on gridview.
p.s I'm using vb.net 2005
12 22834 RedSon 5,000
Recognized Expert Expert
You can use relative directory locations like . and ..
thanx for the reply. Can u show me how to do it caz i'm actually quite new to vb.net?
RedSon 5,000
Recognized Expert Expert
thanx for the reply. Can u show me how to do it caz i'm actually quite new to vb.net?
Assuming that your code executable is running in the directory C:\Documents and Settings\055949 x\ directory... -
File.Move(".\transfer\text.txt", ".\Desktop\AES file\transfer\text.txt");
-
In a shell if you type "cd ." the character '.' is a reference to your current directory. If you type "cd .." the character '..' is a reference to your current directory's parent directory. You can use '.' and '..' anywhere you want. For example say I wanted to move text.txt to the C: root. -
Move("C:\Documents and Settings\055949x\transfer\text.txt","..\..\..\text.text")
-
Or say I wanted to move it to the My Pictures folder for the "All Users" account: -
-
Move("C:\Documents and Settings\055949x\transfer\text.txt","..\..\All Users\Shared Documents\Shared Pictuers\text.text")
-
you have to use the move method. use the file system object FSO
chech the following site.
http://builder.com.com/5100-6371_14-6089850.html
RedSon 5,000
Recognized Expert Expert
walid, you missed the point of the conversation. The OP asked "without having to write the full directory of the file". If you do not want to type out the full directory of the file you can use relative directory paths (ie '.' and '..')
thanx for all the reply..i will try it out..^__^
hi i currently has this code
strfile = Dir("*.txt")
If File.Exists(pat h) Then
File.Move("C:\D ocuments and Settings\055949 x\Desktop\AES file\" & strfile, "C:\Documen ts and Settings\055949 x\Desktop\AES file\transfer\" & strfile)
Label1.Text = ("File moved!")
Else
Label1.Text = ("File does not exist")
End If
i am using gridview and evey file has an id and a button next to it, when i click on the different buttons, the file whose button i click will move. But with the code above, i click on the same button and all the different files will move.. Is there any way to move the file according to the file ID...sry if my explaination is not clear..
hi dear ,
please help me . am using vb.net windows application . how to open the .net solution file with in this application using vb.net code. if any of them knows please help send the code to me ..
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Mel |
last post by:
if you know of dynamic expandable folder using CSS and display function,
please drop me a note
Yours,
Mel
|
by: Bryan Lynn |
last post by:
Is there any way to store a GUID value as a property on a file/folder?
When my app creates new files/folders, I'd like to store a GUID as a
custom property on the file/folder. This way, when the user physically
moves the file/folder using Windows Explorer (and not using my app), I
can use this GUID to detect which files/folders were moved and my app
can internally re-map some things.
Any thoughts?
|
by: Richard |
last post by:
Hi all,
Is there any class in .NET 1.x that will help me set file & folder
permissions for a user? Aka - I would like to do the in code equivalent of
right clicking a folder in file explorer and granting read/write access to a
specific user {not the user running the program}.
Any ideas? Or am I going to have to PInvoke like crazy??
|
by: Ajit |
last post by:
Is there anyway to move attachments from a incoming email
into a specified folder using System.Web.Mail ?
has anyone done this ?
Any help is appreciated.
|
by: John Regan |
last post by:
Hello All
I am trying to find the owner of a file or folder on our network (Windows
2000 Server) using VB.Net and/or API. so I can search for Folders that don't
follow our company's specified folder structure and naming conventions and
then send a Net send message to those users telling them to rectify.
The information I want to get is when you select the file/folder and then:
Properties -> Security Tab -> Advanced Button -> Owner Tab ->...
| |
by: Ajit |
last post by:
Is there anyway to move attachments from a incoming email
into a specified folder using System.Web.Mail ?
has anyone done this ?
Any help is appreciated.
|
by: =?Utf-8?B?SmVmZnJleQ==?= |
last post by:
I made a typo on a Project name (e.g. Wong, instead of Wang). Later on I
renamed the Soution, Project, WebForm., etc, except the file folder name,
back to Wang. Then after I closed the VS.net and went back to the Windows
Explorer, I found out the file folder name was Wong, so I changed it to
Wang. Next time, when I tried to open the Wang project, an error message
showed that VS can not open the Wong Web page (something like that).
...
|
by: kai |
last post by:
Hi, All
I am trying to create a file folder for any login user, and create sub
folders for the user on a web page. After the user login again, he can only
sees his own folder on the Web page. I am planning to use VB2005 or C#.
I look the help files and searched on the web, I cannot find the answer. Is
this possble in ASP.NET 2.0?
Thanks
|
by: anup wadekar |
last post by:
I am able to access the exchange mail boxes of the mounted edb file using Active Directory Services such that i am retrieving the
names of the user's and than setting the mail box to the user.
CDO.Message objMsg;
CDO.DropDirectory objDropDir = new CDO.DropDirectory();
CDO.IMessages objIMesgs;
DirectoryEntry de = srUser.GetDirectoryEntry(); // Where srUser = "anup"
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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: 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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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...
| |