Go to DotNetFunda.com
 Online : 1319 |  Welcome, Guest!   Login
 
Home > Articles > VB.NET > File Handling Methods in VB.NET

Submit Article | Articles Home | Search Articles |

File Handling Methods in VB.NET

red flag  Posted on: 11/7/2009 8:37:22 PM by Abhisek | Views: 1940 | Category: VB.NET | Level: Beginner


This article gives description about different file handling methods present in VB.NET.




Various methods of file handling in VB.NET is given below,

1.Kill(File name with path):-

      This method deletes the said file/files from the disk. The name of the file to be deleted is passed to this method as string type arguments. Files are simply deleted and not moved to recycle-bin. The use of wild card(* and /) is permitted in this function.

Kill("C:\Files\abc.txt") This will delete the file abc.txt locates in C:\Files\

Kill("C:\Files\*.txt") This will delete all the files with .txt extension from C:\Files\

2.FileDateTime(file name with path):-

    This function returns the date and time of creation of the said file. The name of the file to be deleted is passed to this method as string type arguments.

Debug.WriteLine("Date &Time:"&(FileDateTime("C:\Files\abc.txt")))

This may display the the following output in Debug window.

Date & Time: 29/10/2009 09:54:34AM

3.FileLen(file name with path):-

    This method returns the size of the specified file in bytes.The name of the file to be deleted is passed to this method as string type arguments.
Debug.WriteLine("Size of file:"&(FileLen("C:\Files\abc.txt"))) 

This may return the following line in Debug window

Size of file:106

4.MKDir(folder name with path):-

   It creates a new folder(s) in the specified location.

MKDir("C:\Files\MyFile") After execution it will create a new folder MyFile.


5.RmDir(folder name with path):-

   This method delets the folder specified.
RmDir("C:\Files\MyFile") It will remove the folder MyFolder.


6.Dir(file name with path):-

   This method is used to check if the specified file is present or not.

StrCheck = Dir("C:\Files\abc.txt")
If StrCheck = "abc.txt" Then
Debug.WriteLine("File is present")
Else
Debug.WriteLine("File is not present")
EndIf
If the file exists the after execution it will display 'File is present' in debug window.

There are many more methods. I have included the most commonly used methods.



If you like this article, subscribe to our RSS Feed. You can also subscribe via email to our Interview Questions, Codes and Forums section.

Found interesting? Add this to:

| More



Please Sign In to vote for this post.

 
Latest post(s) from Abhisek

Latest Articles
Experience:0 year(s)
Home page:
Member since:Sunday, October 11, 2009
Level:Bronze
Status: [Member]
Biography:Thanks and Regards
Abhisek Panda
Go Green And Save Your Future
 Response(s)
Posted by: Anu4you007 | Posted on: 17 Dec 2009 03:32:30 PM

Good article.

Submit Article

About Us | The Team | Advertise | Contact Us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you found plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 9/3/2010 3:58:26 AM