Can't log in? Can't recover your password? Need help? Contact me via email: unverified@hotmail.com
 
Thread Rating:
  • 2 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5


[VB.Net] System.IO.File Functions
02-20-2011, 03:25 PM
Post: #1
2 Years

1234hotmaster Offline
No code no life

Posts: 2,371
Joined: Aug 2012
Reputation: 0
Currency: 0.00 NSP
[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

Pierce the life fibers with your drill.
02-20-2011, 04:18 PM
Post: #2
2 Years

1llusion Offline
(<marquee>)

Posts: 3,802
Joined: Aug 2012
Reputation: 0
Currency: 0.00 NSP
RE: [VB.Net] System.IO.File Functions
Code:
Imports System.IO
Tongue

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

btw, in the boolean, you use double checking, which is not necessary Smile
Spoiler:
Code:
If integer = 1 = true then
The code will be read:
Quote:If integer is 1 = true = true then

Boolean is set as "true" by default Smile

That means, its more simple to use:
Code:
If integer = 1 then
it will be read:
Quote:If integer is 1 = true then

However, for boolean false you will need it Smile

so:
Code:
If integer = 1 = false then
will be read:
Quote:If integer is 1 = false then

Smile

Staff will never ever ask you for your personal information.
We know everything about you anyway.
02-20-2011, 04:20 PM
Post: #3
2 Years

1234hotmaster Offline
No code no life

Posts: 2,371
Joined: Aug 2012
Reputation: 0
Currency: 0.00 NSP
RE: [VB.Net] System.IO.File Functions
well, still even double checking works Tongue

Glad you liked it. More guides to come Smile

Pierce the life fibers with your drill.
02-20-2011, 04:23 PM
Post: #4
2 Years

1llusion Offline
(<marquee>)

Posts: 3,802
Joined: Aug 2012
Reputation: 0
Currency: 0.00 NSP
RE: [VB.Net] System.IO.File Functions
(02-20-2011 04:20 PM)1234hotmaster Wrote:  well, still even double checking works Tongue

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 Tongue

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, 04:38 PM
Post: #5
2 Years

Coder-san Away
~|0o|~

Posts: 2,623
Joined: Aug 2012
Reputation: 0
Currency: 0.00 NSP
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, 05:13 PM
Post: #6
2 Years

1234hotmaster Offline
No code no life

Posts: 2,371
Joined: Aug 2012
Reputation: 0
Currency: 0.00 NSP
RE: [VB.Net] System.IO.File Functions
Tnx for the examples. Edited Smile

Pierce the life fibers with your drill.
02-21-2011, 04:27 AM
Post: #7
2 Years

Livelife93 Offline
Junior Member

Posts: 13
Joined: Aug 2012
Reputation: 0
Currency: 0.00 NSP
RE: [VB.Net] System.IO.File Functions
Nice things you got goin. good tut.
02-27-2011, 11:30 AM
Post: #8
2 Years

9toes Offline
Member

Posts: 89
Joined: Aug 2012
Reputation: 0
Currency: 0.00 NSP
RE: [VB.Net] System.IO.File Functions
thanks man ! awesome !
this must be transfered in the important thread category .
02-09-2014, 04:40 PM
Post: #9
1 Year

jnoon Offline
Junior Member

Posts: 8
Joined: Jan 2014
Reputation: 0
Currency: 0.00 NSP
RE: [VB.Net] System.IO.File Functions
What will be the source file name


Thread Options


User(s) browsing this thread: 1 Guest(s)