hey guys,
i a very good with batch and all that but not so good with the types of commands that i would like to use in vb.net that will have the same effect as my batch script.
I do know that i can use batch code in vb.net and i know i can call the .bat file but this is not what i want.
it shoud be posible to use vb.net code to do the same thing as the batch code.
This is the correct batch file i got.
what it does is check if a folder exist, if not make one with the todays date.
eg F:\Backups\Backups\2012-01-10
then it will open the folder
:: <summary>
:: This Script will make a Dir Backups\"Corrent Date"
:: YYYY-MM-DD
:: HH:MM:SS
:: </summary>
:: <remarks></remarks>
@echo off
REM <Format Settings>
:: ***********************************
set YourDateFormat=%%D-%%C-%%B
set YourTimeDormat=
REM Add time to the dir? 0=Off 1=On (to be tested)
set TimeDir=0
REM This is the name of the folder. (No Spacers)
set backupfolder=Backups
:: SEE LINE 43
REM </Format Settings>
:: ***********************************
REM Get the date to var
@for /F "tokens=1,2,3,4 delims=/ " %%A in ('Date /t') do @(
set DayW=%%A
set Day=%%B
set Month=%%C
set Year=%%D
set AllDate=%YourDateFormat%
::set AllDate=%%D-%%C-%%B
REM AllDate=%%D-%%C-%%B-%%A
)
REM Get the time to var
@for /F "tokens=1,2,3 delims=:,. " %%A in ('echo %time%') do @(
set Hour=%%A
set Min=%%B
set Sec=%%C
set AllDatem=%%A-%%B
)
REM Get the AM/PM to var
@for /F "tokens=3 delims=: " %%A in ('time /t ') do @(
set AMPM=%%A
)
:: This is your Dir String
:: ***********************************
set dir=%cd%\%backupfolder%\%AllDate%\
:: ***********************************
::echo Your Dir is : %dir%
::pause
REM You can use %AllDatem% %AMPM%
md "%dir%"
::echo Your Dir is: %dir%
%SystemRoot%\explorer.exe "%dir%"
this is some vb.net code snippets that is from another project that i am working on
it will see if a folder exist and if not make a folder
Public Function CreateIfNotExists(ByVal sFolderPath As String) As Boolean
Try
Dim exists As Boolean = False
exists = My.Computer.FileSystem.DirectoryExists(sFolderPath)
If Not exists Then
My.Computer.FileSystem.CreateDirectory(sFolderPath)
Return True
Else
Return True
End If
Catch ex As Exception
Return False
End Try
End Function
Sub md()
Dim sFolderPath As String = "C:\test\" : CreateIfNotExists()
End Sub