Problema con stringa

giovedì 11 dicembre 2008 - 14.46

falk83 Profilo | Newbie

Ciao a tutti,
ho un problema:
dovrei aprire un file excel ma ho problemi con la stringa "Documents and Settings" perché mi da errore nell'apertura del file avendo al suo interni degli spazi vuoi.

System.Diagnostics.Process.Start("EXCEL.exe", "C:\\Documents and Settings\\" + strUtentee + "\\Desktop\\Lista.xls");

Soluzione?

Grazie mille
ciao

aiedail92 Profilo | Expert

Ciao

Per mantenere un argomento con spazi devi racchiuderlo fra virgolette, quindi modificando così il codice dovrebbe andar bene:

System.Diagnostics.Process.Start("EXCEL.exe", "\"C:\\Documents and Settings\\" + strUtentee + "\\Desktop\\Lista.xls\"");

Luca

0v3rCl0ck Profilo | Guru

>Ciao a tutti,

Ciao

>ho un problema:
>dovrei aprire un file excel ma ho problemi con la stringa "Documents
>and Settings" perché mi da errore nell'apertura del file avendo
>al suo interni degli spazi vuoi.
>
>System.Diagnostics.Process.Start("EXCEL.exe", "C:\\Documents
>and Settings\\" + strUtentee + "\\Desktop\\Lista.xls");
>
>Soluzione?

Scrivi l'argument aggiungendo un double quotation:

System.Diagnostics.Process.Start("EXCEL.exe", String.Format(@"""C:\Documents and Settings\{0}\Desktop\Lista.xls""", strUtentee));

>
>Grazie mille
>ciao
>

Enjoy It


-------------------------------------------------------------------
Michael Denny
Senior Software Developer
Microsoft Framework (C# ASP.NET VB.NET)
http://blogs.dotnethell.it/Regulator/

alexmed Profilo | Guru

Ciao

Io di giro questa soluzione che ho trovato nella guida in linea e sembrerebbe funzionare


Dim myDocumentsPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) Dim myProcess As New Process myProcess.StartInfo.FileName = myDocumentsPath + "\Lista.xls" myProcess.StartInfo.Verb = "Open" myProcess.StartInfo.CreateNoWindow = True myProcess.Start()

Ciao

falk83 Profilo | Newbie

Perfetto, grazie a tutti

0v3rCl0ck Profilo | Guru

>Perfetto, grazie a tutti
>

Di niente
Alla prossima...
Ciaooo

-------------------------------------------------------------------
Michael Denny
Senior Software Developer
Microsoft Framework (C# ASP.NET VB.NET)
http://blogs.dotnethell.it/Regulator/
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-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5