[Vb.Net] Class Fichier

Aim :

To create a file type class which includes all one may need for file manipulation:

 

fichier

Imports System.IO
Imports System.Net

Public Class Fichier

‘Author : Saadry Dunkel Consultant
‘Date : 16/03/2018

#Region “<0> [Properties]”

‘Target
Private _Target As String
”’

”’ Define the entire filepath of the selected file
”’

”’
Public Property Target() As String
Get
Return _Target
End Get
Set(ByVal value As String)
_Target = value
End Set
End Property

‘File Existe
Private _Exist As Boolean
”’

”’ Examine if the File exist
”’

”’
Public Property Exist() As Boolean
Get
Return _Exist
End Get
Set(ByVal value As Boolean)
_Exist = value
End Set
End Property

‘File Name
Private _FileName As String
”’

”’ Return the File Name without Extension
”’

”’
Public Property FileName() As String
Get
Return _FileName
End Get
Set(ByVal value As String)
_FileName = value
End Set
End Property

‘File Extension (Extension with dot)
Private _Extension As String
”’

”’ Set or Return the Extension of the file
”’

”’
Public Property Extentsion() As String
Get
Return _Extension
End Get
Set(ByVal value As String)
_Extension = value
End Set
End Property

‘File FullName (File Path + File Name + File Extension)
Private _FullName As String
”’

”’ Returns the Full Path of the File also used when converting the file
”’

”’
Public Property FullName() As String
Get
Return _FullName
End Get
Set(ByVal value As String)
_FullName = value
End Set
End Property

‘File Date Modify
Private _Modify As DateTime
”’

”’ Return the last Modified Date of the file
”’

”’
Public Property Modify() As DateTime
Get
Return _Modify
End Get
Set(ByVal value As DateTime)
_Modify = value
End Set
End Property

‘File Date Created
Private _Created As DateTime
”’

”’ Return the date of Creation of the file
”’

”’
Public Property Created() As DateTime
Get
Return _Created
End Get
Set(ByVal value As DateTime)
_Created = value
End Set
End Property

‘File Date Accessed
Private _Accessed As DateTime
”’

”’ Return the last accessed date of the file
”’

”’
Public Property Accessed() As DateTime
Get
Return _Accessed
End Get
Set(ByVal value As DateTime)
_Accessed = value
End Set
End Property

‘File Size
Private _Size As SizeInfo
”’

”’ Return the converted Size
”’ -Display : Returns the visual content for the reader (size + Scale)
”’ -Valeur : Returns the formated size
”’ -Text : Returns the scale (o, byt, kyt, Gyt, Tyt)
”’ -Raw : Returns the raw size
”’

”’
Public Property Size() As SizeInfo
Get
Return _Size
End Get
Set(ByVal value As SizeInfo)
_Size = value
End Set
End Property

‘File Directory
Private _Path As DirectoryInfo
”’

”’ Returns the Directory location of the File
”’

”’
Public Property Path() As DirectoryInfo
Get
Return _Path
End Get
Set(ByVal value As DirectoryInfo)
_Path = value
End Set
End Property

‘File Parent
Private _Parent As DirectoryInfo
”’

”’ Returns the Parent directory file location
”’

”’
Public Property Parent() As DirectoryInfo
Get
Return _Parent
End Get
Set(ByVal value As DirectoryInfo)
_Parent = value
End Set
End Property
#End Region

#Region “<1> [Structure]”
Public Structure SizeInfo

Public Display As String
Public Valeur As Double
Public Text As String
Public Scale As Size_Scale
Public Raw As Double

End Structure
#End Region
#Region “<2> [Enumeration]”
Public Enum Size_Scale

Bytes
Kilobyte
Megabyte
Gigabyte
Terabyte

End Enum
#End Region

End Class

using System.IO;
using System.Net;

public class Fichier
{
private string _Target;
public string Target
{
private get
{
return _Target;
}

private set
{
_Target = value;
}
}

private bool _Exist;
public bool Exist
{
private get
{
return _Exist;
}

private set
{
_Exist = value;
}
}

private string _FileName;
public string FileName
{
private get
{
return _FileName;
}

private set
{
_FileName = value;
}
}

private string _Extension;
public string Extentsion
{
private get
{
return _Extension;
}

private set
{
_Extension = value;
}
}

private string _FullName;
public string FullName
{
private get
{
return _FullName;
}

private set
{
_FullName = value;
}
}

private DateTime _Modify;
public DateTime Modify
{
private get
{
return _Modify;
}

private set
{
_Modify = value;
}
}

private DateTime _Created;
public DateTime Created
{
private get
{
return _Created;
}

private set
{
_Created = value;
}
}

private DateTime _Accessed;
public DateTime Accessed
{
private get
{
return _Accessed;
}

private set
{
_Accessed = value;
}
}

private SizeInfo _Size;
public SizeInfo Size
{
private get
{
return _Size;
}

private set
{
_Size = value;
}
}

private DirectoryInfo _Path;
public DirectoryInfo Path
{
private get
{
return _Path;
}

private set
{
_Path = value;
}
}

private DirectoryInfo _Parent;
public DirectoryInfo Parent
{
private get
{
return _Parent;
}

private set
{
_Parent = value;
}
}

public struct SizeInfo
{
public string Display;
public double Valeur;
public string Text;
public Size_Scale Scale;
public double Raw;
}

public enum Size_Scale
{
Bytes,
Kilobyte,
Megabyte,
Gigabyte,
Terabyte
}
}

90total visits,1visits today

Share with:
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Telephone

+41 (079) 5111570

Postal address

Saadry Dunkel
2 avenue des Amazones
1224 Chênes-Bougeries

Contact Us




All fields are required.


Sending...

Close contact form
UA-29636309-1