C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » ASP.NET/Web Applications »

File Handling Methods in VB.NET


Posted Date: 04 Nov 2009    Resource Type: Articles    Category: ASP.NET/Web Applications
Author: Abhisek PandaMember Level: Gold    
Rating: 1 out of 5Points: 12



File Handling Methods 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.



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
File Handling Methods  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: ShortCut Keys
Previous Resource: IIS-7 New Future
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET/Web Applications


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use