Lettura file

giovedì 02 marzo 2006 - 18.23

attilio Profilo | Junior Member

Ciao a tutti avrei bisogno di leggere il contenuto di un file ,che non ha estensione ma che è leggibile come txt file...,copiarlo(il contenuto) e creare una'altro file con il testo che ho copiato dal primo.Sapete darmi qualche indicazione sulla strada da seguire?
Grazie

trinity Profilo | Guru

Utilizza la classe System.IO

Ciao
Cirillo Fabio
www.wondernet.biz
fabio@wondernet.biz
http://blogs.dotnethell.it/fabiocirillo/

attilio Profilo | Junior Member

Ho provato guardando msdn a utilizzare un codice tipo questo
protected void ButtonOpen_Click_Click(object sender, System.EventArgs e)
{
String editingFileName = "";
Boolean saveAllowed = true;

// Displays the OpenFileDialog.
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
// Opens the file stream for the file selected by the user.
using (System.IO.Stream userStream = openFileDialog1.OpenFile())
{
this.RtfBoxMain.LoadFile(userStream,
RichTextBoxStreamType.PlainText);
userStream.Close();
}

// Attempts to get the file name selected by the user.
// Failure means that the application does not have
// unrestricted permission to the file.
try
{
editingFileName = openFileDialog1.FileName;
}
catch (Exception ex)
{
if (ex is System.Security.SecurityException)
{
// The application does not have unrestricted permission
// to the file so the save feature will be disabled.
saveAllowed = false;
}
else
{
throw ex;
}
}
}
}
ma openFileDialog1 mi da errore e non viene accettato.
Mi sapete dire perchè?
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