Currently I'm using the following code to extract Zip files.
ZipFile.ExtractToDirectory(folderBrowserDialog1.SelectedPath + "/" + "MySQL Data.zip", folderBrowserDialog1.SelectedPath + "/Release/");
After it's done I'd like to extract another Zip file, so how can I check to see if the zip file has been extracted successfully?
Related
I am trying to append some lines to a *.doc file using:
foreach (var user in usersApproved)
File.AppendAllText(Server.MapPath(("..\\Files\\TFFiles\\" + tid + "\\" + file.Type + "\\")) + Path.GetFileName(file.Title), "Document Signed by: " + user.UserName + Environment.NewLine);
But it produces a corrupted file.
EDITS
I used this answer to produce a *.docx file. But when I try to append the lines I receive the error that "...the file is used by another process" so it fails
The machine is a server where I don't want to install Word/Office so Office Interop is not a viable option.
I do believe that what you need is the Document.Add method. You can read about it here: https://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.documents.add(v=office.14).aspx
If I'm not mistaken, you are trying to treat your file as a common text file while the .doc is a MSWord document
Issue
I have a function which lets the user edit an image when they do this I save this new image to a file to which they I save to the database etc ...
The issue comes as when I try and look for the file I just saved it says it does not exist but it does?
Code
Here I am saving the new file to the TEMP folder:
string newFullTempFolderURL = Path.Combine(Global.TempFolder, newFullFileName + ".png");
_image.Save(newFullTempFolderURL, System.Drawing.Imaging.ImageFormat.Png);
At this point when I check the folder the file is in the folder with the new image.
Then when I go on to uploading the file to the server (Using BITS) I do a check to make sure the file exists:
if (File.Exists(Path.Combine(Global.TempFolder + "\\" + newFullFileName)))
{
}
This then returns false (Not exists) when i can see the file with my own eyes!
Anyone had this same issue?
EDIT1:
newFullFileName already contains .png:
string newFullFileName = string.Format(oldFileName.Substring(0, oldFileName.IndexOf("_") + 1) + DateTime.Now.ToString(), "yyyyMMddhhmmss").Replace(#"/", "").Replace(" ", "").Replace(":", "") + ".png";
As per your edit you are added .png to newFullFileName.. then newFullTempFolderURL will add another .png to your file name.
So ti will become FILENAME.png.png it will return wrong.
remove .png from newfullFilename and
try below
if (File.Exists( Path.Combine(Global.TempFolder, newFullFileName))
{
}
your File.Exists does not contain the file extension as you manually added it when creating "newFullTempFolderURL". You need to append ".png" to the File.Exists check or better yet use File.Exists(newFullTempFolderURL); as it's already been pre-made.
EDIT1:
You are adding ".png" a second time. This is wrong, as the file created is ".png.png", and then you are checking to see if ".png" exists.
Can anyone please suggest a method to open the the files using their
default application in Silverlight application. I am able to get the
full path of the files that I am selecting.
That is for verifying the files before uploading. While using this:
AutomationFactory.CreateObject("WScript.Shell").Run(FileList[_index].filepath);
I get
System.IO.FileNotFoundException
Its not working if the filename contains whitespaces in it.
If you want to open filepaths with spaces you need to add quotes arround your path. Try to use:
"\"" + FILE_PATH + "\""
In your code:
AutomationFactory.CreateObject("WScript.Shell").Run("\"" + FileList[_index].filepath + "\"");
The current version of DropNet (1.8.2.0) seems to be handling the REST portion of things fine, but when I call the final CommitChunkedUpload to complete the upload, I get a dropbox error indicating that the path parameter was in the wrong format.
client.CommitChunkedUpload(upload, "/" + FolderName + "/" + FileName, true);
Leaving off the folder or changing where I want the file to be saved does not resolve things. If I leave off the filename then it tries to save the folder as a file with no contents but does not throw the error.
Am I missing something in the syntax?
I use ASP.net and have a .docx file in website:
Server.MapPath("~") + #"Files\tmp.docx".
I want copy this file to
Server.MapPath("~") + #"Files\Docx\" with "D210" named.
How to copy this file and rename it?
you need to do IO job so do not forget to add Using System.IO;
and this is the code you need:
//1.Prepare the name for renaming
string newName = "D210";
//2.Create the Folder if it doesn't already exist
if(!Directory.Exists(Server.MapPath("~")+#"\Files\Docx\"))
Directory.CreateDirectory(Server.MapPath("~")+#"\Files\Docx\");
//3.Copy the file with the new name
File.Copy(Server.MapPath("~") + #"Files\tmp.docx",Server.MapPath("~")+#"\Files\Docx\"+newName+".docx");