Go to DotNetFunda.com
 Online : 48 |  Welcome, Guest!   Login
 Skip Navigation Links Home > Articles > VB.NET > File Handling Methods in VB.NET
  Win at least 8 gifts every month now! >> Top Performers of this month.   


Notice: If page content has been copied from other sources without proper permission, kindly let us know with details from where it has been copied for further action.

All Articles | Submit Article |

File Handling Methods in VB.NET

 Posted on: 11/7/2009 8:37:22 PM by Abhisek | Views: 273 | Category: VB.NET | Level: Beginner | Print Article
This article gives description about different file handling methods present in VB.NET.

Webmaster says - If this article content has been copied from other websites without proper permission, kindly let us know with details from where it has been copied for further action.


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.



Interesting?   Share and Bookmark this kick it on DotNetKicks.com


Experience:0 year(s)
Home page:
Member since:Sunday, October 11, 2009
Biography:Thanks and Regards
Abhisek Panda
Go Green And Save Your Future
 Latest post(s) from Abhisek

   ◘ Viewing CIL code and Assembly Metadata posted on 11/16/2009 11:51:09 PM
   ◘ Numeric and Date Functions in VB.NET posted on 11/14/2009 2:45:56 AM
   ◘ DataBase Operation In Java Using JDBC posted on 11/7/2009 8:52:51 PM
   ◘ File Handling Methods in VB.NET posted on 11/7/2009 8:37:22 PM
   ◘ What is ADO.NET? posted on 11/2/2009 10:28:08 PM


Submit Article

About Us | The Team | Contact Us | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
All rights reserved to DotNetFunda.Com. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks.
(Best viewed in IE 6.0+ or Firefox 2.0+ at 1024 * 768 or higher)