create subdir

  • Thread starter Thread starter DizWiz
  • Start date Start date
D

DizWiz

Hi!,

Im am using the VB Express Beta2 but cannot figure out how to create a
subdir in the windows directory.

Code:

Dim windowsdir as String
Dim dircreate
dircreate="backup"
windowsdir=environ$("windir")
My.Computer.FileSystem.CreateDirectory(windowsdir)

I want to create the directory "backup" under the windows directory and i
don't want to use the absolute path, what am i missing?

Thanks.

Jacco
 
DizWiz said:
Dim windowsdir as String
Dim dircreate
dircreate="backup"
windowsdir=environ$("windir")
My.Computer.FileSystem.CreateDirectory(windowsdir)

I want to create the directory "backup" under the windows directory and i
don't want to use the absolute path, what am i missing?

\\\
Imports System.IO
..
..
..
My.Computer.FileSystem.CreateDirectory( _
Path.Combine(Environ("windir"), "backup") _
)
///
 
Thanks for the reply, but solved it anothing way:


Dim winenv
Dim dircreate
winenv=environment.GetenvironmentVariable("windir")
dircreate=(winenv)&"\backup"
My.Computer.FileSystem.CreateDirectory(dircreate)

Please comment

Jacco
 
DizWiz said:
Dim winenv
Dim dircreate
winenv=environment.GetenvironmentVariable("windir")
dircreate=(winenv)&"\backup"
My.Computer.FileSystem.CreateDirectory(dircreate)

I recommend to use types for variables, remove the braces around 'winenv'
and use 'Path.Combine' instead of the string concatenation operator.
 
Thanks for you help, but when i use the following code:

System.Console.Write("Accept Systems - %windir% - backup")

My.Computer.FileSystem.CreateDirectory(Path.Combine(Environ("windir"),
"backup"))

Name "path" is not declared

Jacco
 
DizWiz said:
Thanks for you help, but when i use the following code:

System.Console.Write("Accept Systems - %windir% - backup")

My.Computer.FileSystem.CreateDirectory(Path.Combine(Environ("windir"),
"backup"))

Name "path" is not declared

That's why I said that 'Imports System.IO' is required in the file's
'Imports' list.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top