Trovare cartella di windows framework 2.0

martedì 17 gennaio 2006 - 17.53

Gho5t Profilo | Junior Member

ciao a tutti...
vorrei sapere come posso trovare la cartella di windows (es: c:\Windows) in automatico tramite il framework senza doverla digitare di persona.

Grazie mille a chiunque penserà a come risolvere questo problema

totti240282 Profilo | Guru

Dovresti vedere la classe environment dovrebbe esserci la proprietà special folder.....

C'è solo un capitano !!!!!!

totti240282 Profilo | Guru

System.Environment.SpecialFolder.System

C'è solo un capitano !!!!!!

Gho5t Profilo | Junior Member

Già avevo visto quella funzione.. però mi ritorna "c:\Windows\System32"....
io invece vorrei trovare solamente "c:\Windows"

Avete qualche altro suggerimento?



UN UOMO NON MUORE PER QUALCOSA IN CUI NON CREDE

totti240282 Profilo | Guru

bè da li è facile ti fai una piccola funzioncina e hai risolto !!!!

C'è solo un capitano !!!!!!

Gho5t Profilo | Junior Member

ho trovato questo script che inizialmente era per vb6, poi l'ho aggiustato per .net..

Private Declare Function GetWindowsDirectory Lib "kernel32.dll" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long


Public Function GetTheWindowsDirectory() As String

Dim strWindowsDir As String ' Variable to return the path of Windows Directory
Dim lngWindowsDirLength As Long ' Variable to return the the lenght of the path

strWindowsDir = Space(250) ' Initilize the buffer to receive the string

Dim ip As Long = 250
lngWindowsDirLength = GetWindowsDirectory(strWindowsDir, ip) ' Read the path of the windows directory

strWindowsDir = strWindowsDir.Substring(0, 255)

Return strWindowsDir
End Function

effettivamente mi restituisce c:\Windows ....
però mi da un'errore nella riga in cui richiamo "GetWindowsDirectory(strWindowsDir, ip)" molto strano:

"A call to PInvoke function 'Zip!Zip.frmMain::GetWindowsDirectory' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature."

qualcuno mi può aiutare???

UN UOMO NON MUORE PER QUALCOSA IN CUI NON CREDE
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2025
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5