2017-04-01 15 views
0

次のコードは、Tempフォルダにreadonlyフォルダを作成します。コードを次の読み取り専用でないフォルダを作成する方法

System.IO.Directory.CreateDirectory(path:=IO.Path.GetTempPath & "Myfolder") 

directorySecurity:=一部は読み取り専用ではないフォルダを作成する方法を、そう

System.IO.Directory.CreateDirectory(path:=IO.Path.GetTempPath & "Myfolder", directorySecurity:=I need help here) 

を修理する必要があります。

答えて

0

ReadOnlyはセキュリティオプションではなく、属性です。フォルダを作成しても、既定では読み取り専用にしてはいけません。、のインスタンスを作成し、Attributes propertyを変更することができます。パスを構築するときには、Path.Combine()を使用することを強くお勧めします。

Dim DirPath As String = Path.Combine(Path.GetTempPath(), "Myfolder") 
Directory.CreateDirectory(DirPath) 

Dim Dir As New DirectoryInfo(DirPath) 
Dir.Attributes = Dir.Attributes And Not FileAttributes.ReadOnly 'Bitwise removal. 
+0

右クリック> [プロパティ]を選択すると、ReadOnlyが表示されますか? –

+0

@KenKeniee:それは奇妙です... TEMPフォルダは読み取り専用に設定されていますか?管理者権限でアプリケーションを実行するとどうなりますか? –

+1

ここで解決策を見つけました:http://stackoverflow.com/questions/14853105/give-folder-full-access-when-created?rq=1 –

関連する問題