Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi everybody :)

I wanna create a folder in My Documents, named "My Information" for example!

And customize its ICON by placing a "Desktop.ini" file into that.

So I wrote this code which works perfect, but I don't know why it does not show the ICON as expected :(

'Create Directory
If Not My.Computer.FileSystem.DirectoryExists(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\My Information") Then
   System.IO.Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\My Information")
End If
'Create File
Dim FileContent As String = "[.ShellClassInfo]" + vbNewLine + "IconFile=%ProgramFiles%\Company\Product\Program.exe" + vbNewLine + "IconIndex=0" + vbNewLine + "InfoTip=Information collected using our application"
If Not My.Computer.FileSystem.FileExists(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\My Information\Desktop.ini") Then
   My.Computer.FileSystem.WriteAllText(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\My Information\Desktop.ini", FileContent, False)
End If
Dim FileDetail As IO.FileInfo = My.Computer.FileSystem.GetFileInfo(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\My Information\Desktop.ini")
FileDetail.Attributes = IO.FileAttributes.Hidden + IO.FileAttributes.System

Posted

Hi PlausiblyDamp,

Thank you very much for your tip.

However, it won't work :(

I really don't know what should I do.

Even if I use Windows to Customize this folder for me, it will create the same file as me!

When Windows creates it, it works! :confused:

Please help me :(

Posted

Well, thanks :)

This code must work now, but it's not :(

   Declare Auto Function PathMakeSystemFolder Lib "shlwapi.dll" Alias "PathMakeSystemFolder" (ByVal pszPath As String) As Integer
   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       'Create Directory
       If Not My.Computer.FileSystem.DirectoryExists(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\My Information") Then
           System.IO.Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\My Information")
       End If
       PathMakeSystemFolder(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\My Information")
       'Create File
       Dim FileContent As String = "[.ShellClassInfo]" + vbNewLine + "IconFile=%ProgramFiles%\Company\Product\Program.exe" + vbNewLine + "IconIndex=0" + vbNewLine + "InfoTip=Information collected using our application"
       If Not My.Computer.FileSystem.FileExists(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\My Information\Desktop.ini") Then
           My.Computer.FileSystem.WriteAllText(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\My Information\Desktop.ini", FileContent, False)
       End If
       Dim FileDetail As IO.FileInfo = My.Computer.FileSystem.GetFileInfo(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\My Information\Desktop.ini")
       FileDetail.Attributes = IO.FileAttributes.Hidden + IO.FileAttributes.System
   End Sub

Posted

Hi,

Thank you very much for your help :)

So this final code still does not work on XP:

   Declare Auto Function PathMakeSystemFolder Lib "shlwapi.dll" Alias "PathMakeSystemFolder" (ByVal pszPath As String) As Integer
   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       'Create Directory
       If Not My.Computer.FileSystem.DirectoryExists(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\My Information") Then
           System.IO.Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\My Information")
       End If

       'Create File
       Dim FileContent As String = "[.ShellClassInfo]" + vbNewLine + "IconFile=%ProgramFiles%\Company\Product\Program.exe" + vbNewLine + "IconIndex=0" + vbNewLine + "InfoTip=Information collected using our application"
       If Not My.Computer.FileSystem.FileExists(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\My Information\Desktop.ini") Then
           My.Computer.FileSystem.WriteAllText(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\My Information\Desktop.ini", FileContent, False)
       End If

       PathMakeSystemFolder(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\My Information")
   End Sub

:(

  • Administrators
Posted

No idea then, just tried it on my pc and other than changing the path in the line

Dim FileContent As String = "[.ShellClassInfo]" + vbNewLine + "IconFile=%ProgramFiles%\Company\Product\Program.exe" + vbNewLine + "IconIndex=0" + vbNewLine + "InfoTip=Information collected using our application"

to point to an executable that exists on my hard drive it worked perfectly. I am running windows 7 but that shouldn't make a difference as the API has been in existence since NT 4 with IE 4!

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...