Login LOGIN WITH FACEBOOK Register LOGIN TO REMOVE THE ADS


Scroll me back to the top !



[VB.Net] System.IO.File Functions
Author Message
1234hotmaster Offline
Baiting Expert
Posts: 2,468

Reputation: 69
Thanks received: 61
Thanks given: 20
HackCommunity Coins: 309
Post: #1
[VB.Net] System.IO.File Functions
IO.File.AppendText & IO.File.AppendAllText & IO.File.CreateText & IO.File.WriteAllText & IO.File.WriteAllLines & IO.File.WriteAllBytes


Explanation: These functions are used to create TextFiles or write bytes.

Example:
Code:
IO.File.AppendText("C:\text.txt")
IO.File.AppendAllText("C:\text.txt", Textbox1.text)
IO.File.CreateText("C:\Text.txt")
IO.File.WriteAllText("C:\test.txt", Textbox1.text)
IO.File.WriteAllLines("C:\text.txt", Textbox1.text)
IO.File.WriteAllBytes("C:\file.exe", Nothing)


Format:
Code:
IO.File.AppendText(Path)
IO.File.AppendAllText(Path, Contents)
IO.File.CreateText(Path)
IO.File.WriteAllText(Path, Contents)
IO.File.WriteAllLines(Path, Contents)
IO.File.WriteAllBytes(Path, Byte)







IO.File.Copy


Explanation: This function is used to copy files.

Example:
Code:
IO.File.Copy(Application.ExecutablePath, "C:\copied.exe")


Format:
Code:
IO.File.Copy(SourceFileName, Destinationfilename)





IO.File.Create


Explanation: Creates a file of any format.

Example:
Code:
IO.File.Create("C:\new.exe")


Format:
Code:
IO.File.Create(Path)







IO.File.Delete


Explanation: Deletes an existing file.

Example:
Code:
IO.File.Delete("C:\file.exe")


Format:
Code:
IO.File.Delete(Path)







IO.File.Exists


Explanation: Gets a boolean ( True or False ) value whether the file exists or no.

Example:
Code:
If IO.File.Exists("C:\file.exe") = True Then
MsgBox("File Exists")
Else
MsgBox("File Does not Exist")
End If


Format:
Code:
IO.File.Exists(Path)







IO.File.GetAttributes


Explanation: Gets the value of a file's Attribute.

Example:
Code:
MsgBox(IO.File.GetAttributes("C:\hidden.exe"))


Format:
Code:
IO.File.GetAttributes(Path)







IO.File.GetCreationTime & IO.File.GetCreationTimeUtc & IO.File.GetLastAccessTime & IO.File.GetLastAccessTimeUtc & IO.File.GetLastWriteTime


Explanation: Gets values of a file's Creation time, which the time a file is created and its date for utc ones. And gets its last editing time or creation time or when its last opened.

Example:
Code:
IO.File.GetCreationTime("C:\file.exe")
IO.File.GetCreationTimeUtc("C:\file.exe")
IO.File.GetLastAccessTime("C:\file.exe")
IO.File.GetLastAccessTimeUtc("C:\file.exe")
IO.File.GetLastWriteTime("C:\file.exe")


Format:
Code:
IO.File.GetCreationTime(Path)
IO.File.GetCreationTimeUtc(Path)
IO.File.GetLastAccessTime(Path)
IO.File.GetLastAccessTimeUtc(Path)
IO.File.GetLastWriteTime(Path)







IO.File.Move


Explanation: Moves a file to a new directory. Same like Cut and Paste.

Example:
Code:
IO.File.Move(Application.ExecutablePath, "C:\moved.exe")


Format:
Code:
IO.File.Move(SourceFileName, Destinationfilename)







IO.File.Open & IO.File.OpenRead & IO.File.OpenText & IO.File.OpenWrite


Explanation: Open's a file for either reading or writing to it.

Example:
Code:
IO.File.Open("C:\file.exe", IO.FileMode.Open)
Textbox1.text = IO.File.OpenRead("C:\text.txt")
Textbox1.text = IO.File.OpenText("C:\text.txt")
IO.File.OpenWrite("C:\text.txt")


Format:
Code:
IO.File.Open(Path, Mode)
IO.File.OpenRead(Path)
IO.File.OpenText(Path)
IO.File.OpenWrite(Path)







IO.File.ReadAllBytes & IO.File.ReadAllLines & IO.File.ReadAllText


Explanation: Opens a file to read its byte array or all Textlines or its text.

Example:
Code:
Dim aByteArray As Byte() = IO.File.ReadAllBytes("C:\file.exe")
Dim aStringArray As String() = IO.File.ReadAllLines("C:\text.txt")
Dim aString As String = IO.File.ReadAllText("C:\text.txt")


Format:
Code:
IO.File.ReadAllBytes(Path)
IO.File.ReadAllLines(Path)
IO.File.ReadAllText(Path)







IO.File.Replace


Explanation: Rewrites a existing file and makes a backup of it.

Example:
Code:
IO.File.Replace(Application.ExecutablePath, "C:\copy.exe", "C:\backup.exe")


Format:
Code:
IO.File.Replace(SourceFileName, DestinationFileName, DestinationBackupFileName)






IO.File.SetAttributes


Explanation: Sets or changes a file's attribute.

Example:
Code:
IO.File.SetAttributes("C:\Unhidden.exe", FileAttribute.Hidden)


Format:
Code:
IO.File.SetAttributes(Path, FileAttributes)







IO.File.SetCreationTime & IO.File.SetCreationTimeUtc & IO.File.SetLastAccessTime & IO.File.SetLastAccessTimeUtc & IO.File.SetLastWriteTime


Explanation: Can set a file's creation date, the same date and time it got created or its last opened date and time or its last Edited time. Very useful for virus makers to fool the opener to think the binded file's creation date is like 2 years ago.

Example:
Code:
IO.File.SetCreationTime("C:\file.exe", Date.Today)
IO.File.SetCreationTimeUtc("C:\file.exe", Date.UtcNow)
IO.File.SetLastAccessTime("C:\file.exe", Date.Now)
IO.File.SetLastAccessTimeUtc("C:\file.exe", Date.Now)
IO.File.SetLastWriteTime("C:\file.exe", Date.Now)


Format:
Code:
IO.File.SetCreationTime(Path, Date)
IO.File.SetCreationTimeUtc(Path, Date)
IO.File.SetLastAccessTime(Path, Date)
IO.File.SetLastAccessTimeUtc(Path, Date)
IO.File.SetLastWriteTime(Path, Date)








File.Attributes: The Properties of files. The VB Attributes are:
  • FileAttribute.Archive
  • FileAttribute.Directory
  • FileAttribute.Hidden
  • FileAttribute.Normal
  • FileAttribute.ReadOnly
  • FileAttribute.System
  • FileAttribute.Volume



Boolean: The Conditions that can connect codes. There are known booleans as:
  • True ( Saying something is True )
  • False ( Saying something is False )
  • = ( Saying something is equal to another Code )
  • <> ( Saying something is not equal to another Code )
  • < ( Saying something is bigger then the Code's value )
  • > ( Saying something is smaller then the Code's Value )



Examples:
Code:
If IO.File.Exists("C:\file.exe") = true then
If IO.File.Exists("C:\file.exe") = false then
If integer = 1 = true then
If integer <> 1 = true then
If integer < 1 = true then
If integer > 1 = true then












Writed by 1234hotmaster. Please don't leech or give credits and source if you share.

Have a Great day Smile
Bueno.
(This post was last modified: 02-20-2011 07:12 PM by 1234hotmaster.)
02-20-2011 05:25 PM
SEARCH QUOTE
1llusion Offline
(<marquee>)
Posts: 3,534

Reputation: 87
Thanks received: 197
Thanks given: 29
HackCommunity Coins: 1,050
Post: #2
RE: [VB.Net] System.IO.File Functions
Code:
Imports System.IO
:P

Nice guide!!! I really like it!!!

btw, in the boolean, you use double checking, which is not necessary Smile
Staff will never ever ask you for your personal information.
We know everything about you anyway.
(This post was last modified: 02-20-2011 06:19 PM by 1llusion.)
02-20-2011 06:18 PM
WEBSITE SEARCH QUOTE
1234hotmaster Offline
Baiting Expert
Posts: 2,468

Reputation: 69
Thanks received: 61
Thanks given: 20
HackCommunity Coins: 309
Post: #3
RE: [VB.Net] System.IO.File Functions
well, still even double checking works :P

Glad you liked it. More guides to come Smile
Bueno.
(This post was last modified: 02-20-2011 06:21 PM by 1234hotmaster.)
02-20-2011 06:20 PM
SEARCH QUOTE
1llusion Offline
(<marquee>)
Posts: 3,534

Reputation: 87
Thanks received: 197
Thanks given: 29
HackCommunity Coins: 1,050
Post: #4
RE: [VB.Net] System.IO.File Functions
(02-20-2011 06:20 PM)1234hotmaster Wrote:  well, still even double checking works :P

Glad you liked it. More guides to come Smile

Yeh, but it slows down the process a little bit. And also more words = more complicated :P

Looking forward for more great guides!!!!!!!
Staff will never ever ask you for your personal information.
We know everything about you anyway.
02-20-2011 06:23 PM
WEBSITE SEARCH QUOTE
Coder-san Away
~|0o|~
Posts: 2,338

Reputation: 104
Thanks received: 255
Thanks given: 122
HackCommunity Coins: 1,411
Post: #5
RE: [VB.Net] System.IO.File Functions
Nice thread, keep it up. Smile

You can show the return values more clearly like:

Code:
Dim aByteArray As Byte() = IO.File.ReadAllBytes("C:\file.exe")
Dim aStringArray As String() = IO.File.ReadAllLines("C:\text.txt")
Dim aString As String = IO.File.ReadAllText("C:\text.txt")
[Image: rytwG00.png]
Redcat Revolution!
02-20-2011 06:38 PM
SEARCH QUOTE
1234hotmaster Offline
Baiting Expert
Posts: 2,468

Reputation: 69
Thanks received: 61
Thanks given: 20
HackCommunity Coins: 309
Post: #6
RE: [VB.Net] System.IO.File Functions
Tnx for the examples. Edited Smile
Bueno.
02-20-2011 07:13 PM
SEARCH QUOTE
Livelife93 Offline
Member
Posts: 18

Reputation: 0
Thanks received: 0
Thanks given: 0
HackCommunity Coins: 0
Post: #7
RE: [VB.Net] System.IO.File Functions
Nice things you got goin. good tut.
02-21-2011 06:27 AM
SEARCH QUOTE
9toes Offline
Member
Posts: 78

Reputation: 0
Thanks received: 0
Thanks given: 0
HackCommunity Coins: 22
Post: #8
RE: [VB.Net] System.IO.File Functions
thanks man ! awesome !
this must be transfered in the important thread category .
(This post was last modified: 02-27-2011 11:15 PM by 9toes.)
02-27-2011 01:30 PM
SEARCH QUOTE
jnoon Offline
Member
Posts: 7

Reputation: 0
Thanks received: 0
Thanks given: 0
HackCommunity Coins: 9
Post: #9
RE: [VB.Net] System.IO.File Functions
What will be the source file name
02-09-2014 06:40 PM
SEARCH QUOTE


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
QUESTION Getting VB C++ to write a batch file fumsent 6 272 10-24-2013 07:28 AM
Last Post: Deque
[VB.Net] Making a cool File/Directory Search Coder-san 26 3,498 09-29-2013 09:02 PM
Last Post: hellomen
QUESTION WebBrowser to replace SWF file load!! MikiMiki12 0 230 09-20-2013 12:08 AM
Last Post: MikiMiki12
Motion dectection Security System [Source] Thewrath 4 387 09-16-2013 08:26 PM
Last Post: Thewrath
Solved -  File Downloader isn't working? unnamed 11 322 08-14-2013 04:14 PM
Last Post: chmod
how to load text file into list box in VB ? Dlovan-IT 1 232 08-14-2013 09:28 AM
Last Post: ArkPhaze
QUESTION hacking the exe file Wild Hacker 17 3,572 04-19-2013 10:10 AM
Last Post: ArkPhaze
VB - Import Text From .txt file? -- Help! Morpheus 4 298 03-22-2013 12:38 AM
Last Post: ddee
TUTORIAL [VB.Net] Regular Expressions - Basic Regex to filter text from any file Coder-san 3 709 01-23-2013 10:06 AM
Last Post: Deque
[vb6] Get Name Of File sylar 0 291 08-24-2012 06:48 PM
Last Post: sylar