VB.NET

Moderators: seancampbell
Number of threads: 4022
Number of posts: 10035

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
I need help, badly!! Posted by compuwizjr on 21 Oct 2005 at 7:44 AM
I'm working on a personalized wipe-out disk for a friend, but I can't figure out how to make it delete the file the person specifies. You see, I have a text box(txtFile) where the user will type in the name of the file, a text box(txtSource) where the user will type in the location of the file, then the start button(txtDelete), but my problem is that I don't know the code to delete the file specified in the "txtFile" box. Can some one help me?
Report
Re: I need help, badly!! Posted by dirtyharry on 21 Oct 2005 at 8:52 AM
: I'm working on a personalized wipe-out disk for a friend, but I can't figure out how to make it delete the file the person specifies. You see, I have a text box(txtFile) where the user will type in the name of the file, a text box(txtSource) where the user will type in the location of the file, then the start button(txtDelete), but my problem is that I don't know the code to delete the file specified in the "txtFile" box. Can some one help me?
:

I think there is a command 'kill' which can remove files.
Example: Kill ("c:\temp\test.txt")
So in your case : Kill (txtSource.Text & txtFile.Text)

To remove directories use: rmdir
Example: Rmdir ("c:\temp\")
Note that the last function only works if ALL files AND folders are removed in that folder so the folder is empty.

Good luck!
Marty
Report
Re: I need help, badly!! Posted by compuwizjr on 21 Oct 2005 at 11:45 AM
: : I'm working on a personalized wipe-out disk for a friend, but I can't figure out how to make it delete the file the person specifies. You see, I have a text box(txtFile) where the user will type in the name of the file, a text box(txtSource) where the user will type in the location of the file, then the start button(txtDelete), but my problem is that I don't know the code to delete the file specified in the "txtFile" box. Can some one help me?
: :
:
: I think there is a command 'kill' which can remove files.
: Example: Kill ("c:\temp\test.txt")
: So in your case : Kill (txtSource.Text & txtFile.Text)
:
: To remove directories use: rmdir
: Example: Rmdir ("c:\temp\")
: Note that the last function only works if ALL files AND folders are removed in that folder so the folder is empty.
:
: Good luck!
: Marty
:
: Thanks for your help, but now I have another problem. I also have "Cancel" button, and I can't figure out what kind of code to use for the button to make the delete action stop.


Report
Re: I need help, badly!! Posted by dirtyharry on 21 Oct 2005 at 1:39 PM
: : : I'm working on a personalized wipe-out disk for a friend, but I can't figure out how to make it delete the file the person specifies. You see, I have a text box(txtFile) where the user will type in the name of the file, a text box(txtSource) where the user will type in the location of the file, then the start button(txtDelete), but my problem is that I don't know the code to delete the file specified in the "txtFile" box. Can some one help me?
: : :
: :
: : I think there is a command 'kill' which can remove files.
: : Example: Kill ("c:\temp\test.txt")
: : So in your case : Kill (txtSource.Text & txtFile.Text)
: :
: : To remove directories use: rmdir
: : Example: Rmdir ("c:\temp\")
: : Note that the last function only works if ALL files AND folders are removed in that folder so the folder is empty.
: :
: : Good luck!
: : Marty
: :
: : Thanks for your help, but now I have another problem. I also have "Cancel" button, and I can't figure out what kind of code to use for the button to make the delete action stop.
:
:
:

Well you can't really stop one Kill command. What you can do is stop a loop in which more files are deleted.
For example if you delete 100 files in a directory using a while loop, create a public boolean continue which is set on true initially. I you press cancel this boolean will be set to false so that the loop won't continue.

Example:
general
public continue as boolean
-----
public sub deleteFiles ()
continue = true
While i < numberOfFiles And continue = true
Kill(fileList.item(i)text)
i = i + 1
end sub


Something like that should work. Note that if you delete 100 files at once, you only have a couple of seconds to cancel. But if the user of your program deletes about 10 files (or less) you won't get the chance to cancel.
Instead I would recommend a prompt box which asks for comfirmation so the user is sure.

Good luck!
Marty
Report
Re: I need help, badly!! Posted by compuwizjr on 24 Oct 2005 at 11:33 AM
: : : : I'm working on a personalized wipe-out disk for a friend, but I can't figure out how to make it delete the file the person specifies. You see, I have a text box(txtFile) where the user will type in the name of the file, a text box(txtSource) where the user will type in the location of the file, then the start button(txtDelete), but my problem is that I don't know the code to delete the file specified in the "txtFile" box. Can some one help me?
: : : :
: : :
: : : I think there is a command 'kill' which can remove files.
: : : Example: Kill ("c:\temp\test.txt")
: : : So in your case : Kill (txtSource.Text & txtFile.Text)
: : :
: : : To remove directories use: rmdir
: : : Example: Rmdir ("c:\temp\")
: : : Note that the last function only works if ALL files AND folders are removed in that folder so the folder is empty.
: : :
: : : Good luck!
: : : Marty
: : :
: : : Thanks for your help, but now I have another problem. I also have "Cancel" button, and I can't figure out what kind of code to use for the button to make the delete action stop.
: :
: :
: :
:
: Well you can't really stop one Kill command. What you can do is stop a loop in which more files are deleted.
: For example if you delete 100 files in a directory using a while loop, create a public boolean continue which is set on true initially. I you press cancel this boolean will be set to false so that the loop won't continue.
:
: Example:
: general
: public continue as boolean
: -----
: public sub deleteFiles ()
: continue = true
: While i < numberOfFiles And continue = true
: Kill(fileList.item(i)text)
: i = i + 1
: end sub
:
:
: Something like that should work. Note that if you delete 100 files at once, you only have a couple of seconds to cancel. But if the user of your program deletes about 10 files (or less) you won't get the chance to cancel.
: Instead I would recommend a prompt box which asks for comfirmation so the user is sure.
:
: Good luck!
: Marty
:
Okay, so I used the exact code you gave me for the kill command, and I don't exactly understand the code for my cancel button, but I also need help with how to make a prompt box to ask for confirmation.
CompuWizJR

Report
Re: I need help, badly!! Posted by compuwizjr on 24 Oct 2005 at 11:38 AM
: : : : : I'm working on a personalized wipe-out disk for a friend, but I can't figure out how to make it delete the file the person specifies. You see, I have a text box(txtFile) where the user will type in the name of the file, a text box(txtSource) where the user will type in the location of the file, then the start button(txtDelete), but my problem is that I don't know the code to delete the file specified in the "txtFile" box. Can some one help me?
: : : : :
: : : :
: : : : I think there is a command 'kill' which can remove files.
: : : : Example: Kill ("c:\temp\test.txt")
: : : : So in your case : Kill (txtSource.Text & txtFile.Text)
: : : :
: : : : To remove directories use: rmdir
: : : : Example: Rmdir ("c:\temp\")
: : : : Note that the last function only works if ALL files AND folders are removed in that folder so the folder is empty.
: : : :
: : : : Good luck!
: : : : Marty
: : : :
: : : : Thanks for your help, but now I have another problem. I also have "Cancel" button, and I can't figure out what kind of code to use for the button to make the delete action stop.
: : :
: : :
: : :
: :
: : Well you can't really stop one Kill command. What you can do is stop a loop in which more files are deleted.
: : For example if you delete 100 files in a directory using a while loop, create a public boolean continue which is set on true initially. I you press cancel this boolean will be set to false so that the loop won't continue.
: :
: : Example:
: : general
: : public continue as boolean
: : -----
: : public sub deleteFiles ()
: : continue = true
: : While i < numberOfFiles And continue = true
: : Kill(fileList.item(i)text)
: : i = i + 1
: : end sub
: :
: :
: : Something like that should work. Note that if you delete 100 files at once, you only have a couple of seconds to cancel. But if the user of your program deletes about 10 files (or less) you won't get the chance to cancel.
: : Instead I would recommend a prompt box which asks for comfirmation so the user is sure.
: :
: : Good luck!
: : Marty
: :
: Okay, so I used the exact code you gave me for the kill command, and I don't exactly understand the code for my cancel button, but I also need help with how to make a prompt box to ask for confirmation.
: CompuWizJR
:
:
With the code you just gave me, I get the following Task List build error:Statement cannot appear within a method body. End of method assumed.
It's from the "Public Sub" part of the code. What does it mean, and how do I fix it?
CompuWizJR




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.