It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
After Creating an Excel file using C#, I'm trying to open the file, and get the following exception:
"excel cannot open the file because the file format or file extension is not valid. verify that the file has not been corrupted and that the file extention matches the format of the file."
Any suggestions?
Without any code and by reading the error, I have the suspect that you're specifing the wrong extension in the path when you save the file, which is a common mistake:
string path = "C:\\excelfile.xls"; //or xlsx as said #JMK
Related
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am facing problem with "Access one xml file from 2 different applications at same time".
But it shows error code is "access denied, because another process using the file".
I applied all lock methods, but no use (same error).
Setting the correct FileShare enumeration value when instantiating the underlying FileStream allows you to control this.
Ref.: http://msdn.microsoft.com/en-us/library/system.io.fileshare.aspx
Even if it would be possible for two applications to write to the same file at the same time, the file would be corrupted. I recommend you to use a database instead.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Hi I am trying to delete files from a directory.It is able to delete the first file ,but after that
it is not able to delete other files.It is showing error message "the process cannot access the file as it used by other process.
My code for deleting is
foreach(FileInfo file in files)
{
file.delete()
}
Please help
The operating system will not let you delete a file in use by another process.
Use this tool to find out what process is accessing the files you are trying to delete:
Process Explorer v15.3
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I'm trying to access a file inside my project.
So I would create a new folder called Files and inside that folder contains various HTML files.
Is there anyway that I can access those files by going to "Program/Files/file.html" or similar.
Do you mean something like this?
using System.IO;
...
string folderPath = AppDomain.CurrentDomain.BaseDirectory; // or whatever folder you want to load..
foreach (string file in Directory.EnumerateFiles(folderPath, "*.html"))
{
string contents = File.ReadAllText(file);
}
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I want to write a program that will take a mp3 file as a input and output will be the words that are available in that mp3 file. For example, I have a file name test.mp3, that contains some sentences (e.g. how are you? I am fine. What is your name?), now I want to parse the mp3 file so that I can get all words/sentence that are available in test.mp3 file. I prefer .NET(c#) code.
If file format is .wav, then It is okay for me.
Please help me about the issue.
-Thanks,
Arefin
Have a look at http://msdn.microsoft.com/en-us/library/system.speech.recognition.aspx . Maybe you'll find something there.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I am trying to save an xml file to C:\Program file\MyApplicationFolder\my.xml, but I am receving an access denied error.
How can I save the file successfully?
Please help me! Here is my code
using(XmlWritter write=XmlWritter.Create(Application.StartUppath){write.WriteStartDocument();
write.WriteStartElement("Setting");
write.WriteElementString("Username", name);
write.WriteElementString("Password", psw);
write.WriteEndElement();
write.WriteEndDocument();
C:\Program Files is a restricted folder. Only administrators can modify the contents of this folder.
Use this code to generate a path:
FileName = Path.Combine( _
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), _
"MyApplicationFolder\My.xml" _
)
This saves to a folder the user has access to:
C:\Users\<username>\AppData\Roaming\MyApplicationFolder\My.xml
Try saving to the per-user Application Data directory instead.