J'ai eu le code suivant dispersé tout au long de mon programme. Cependant, je semble toujours avoir l'erreur ci-dessous. Même si j'utilise un «crochet» pour disposer de ressources, je ne sais toujours pas pourquoi cela se produit.Comment "Unaccess" un fichier afin que d'autres parties du programme peuvent y accéder
Erreur:
The Process cannot access the file "the file path" because it is being used by another process.
code:
string folderpath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "AGoogleHistory");
string filecreate;
private void restoreTbasToolStripMenuItem_Click(object sender, EventArgs e)
{
using(StreamReader sr = new StreamReader(filecreate))
{
string s = sr.ReadToEnd();
MessageBox.Show(s, "History", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
try
{
browser.Navigate(new Uri(Address));
using(StreamWriter sw = new StreamWriter(filecreate))
{
sw.WriteLine(Address);
}
}
catch(System.UriFormatException)
{
return;
}
private void clearToolStripMenuItem_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Are You Sure", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
{
File.Delete(filecreate);
}
else
{
}
}
Votre image a été un lien vers la page d'accueil imgur. Je l'ai enlevé. S'il vous plaît ne pas poster des images d'erreurs de toute façon, juste du texte, s'il vous plaît. – Blorgbeard