Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
How to attach some files or folders as one compressed file to an email in c# ?
For example assume I have 2 folders and 3 files and it is necessary that I attach these files and folders into one compressed file.
You can use DotNetZip for compressing the folder as there is a method exactly for this task :
using (var zip = new ZipFile())
{
zip.AddDirectory("DirectoryOnDisk", "rootInZipFile");
zip.Save("MyFile.zip");
}
After that you have to simply attach it to the email (
.AddAttachment(..)
).
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I have an interesting problem, my system is a winforms, but also console app, that watchers for file changes in a folder.
Everything works great, but if that folder is a local git repo and there are operations that would change the files, the file watcher is not fired!
ex:
git restore 1.txt
The above removes the change from the git working tree and will not trigger the filewatcher.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I have a program for zipping files , but I don't know how to make it to zip automatically in certain time (for example every Friday at 5 pm). It has to be like the link in description LINK
You can schedule it as a Task
https://technet.microsoft.com/en-us/library/cc748993(v=ws.11).aspx
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I was trying to create a zip file programmatically in C#.
Unfortunately the below line keeps throwing error for some unknown reason.
Package zip = ZipPackage.Open("E:\\Logs",System.IO.FileMode.OpenOrCreate,
System.IO.FileAccess.ReadWrite);
Access to the path "E:\Logs" is denied.
I tried some diff piece of code, but I had the same issue
FileStream fs = File.Create("E:\\Logs");
Not sure what could be the reason. Appreciate if this could be resolved.
First you must use \\ instead of \.
Second, Open method accept a file name. So you must use it like this:
Package zip = ZipPackage.Open("D:\\a.zip",System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.ReadWrite);
It gives you the answer in the error, you don't have access to that area, you're trying to create a file in the root directory of your drive and you don't have the user rights to do that, it's the same if you don't do it programatically, if you try to create a file named logs at the root of C on any modern version of Windows you will get told you need to elevate to administrator access.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a windows form application which works with data sets that are text files. I tested the application on other systems and it works, properly.But for running the application the data sets must copy into C Drive directly. Is there any solution for running the application without copying the data sets into C Drive or any directory?
The form of my script to read the dataset?
StreamReader fileitem = new StreamReader("c:\\dataset.txt");
I hope to get your detailed comments.
It looks like you are looking for System.Windows.Forms.Application.StartupPath. Source
That is an environment variable, which gives you the path for where your exe file started. This means, if you run your app from a USB drive G:\MyApp. You could use:
StreamReader fileitem = new StreamReader(Path.Combine(Application.StartupPath, "dataset.txt"));
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
hi i am creating a c# application that monitor the files that has been copied , the aim of program is to alert user that there is a file has been copied , i know the file system watcher class , but it has only 4 events , change or create or delete or rename , is there a way to know if file has been copied in or out of system ?
When a file is copied into the system you will also get a change or create event. But if it is simply accessed (which is what happens when it is copied) FileSystemWatcher is of no use.
You can use Auditing file and folder access feature of Windows.
The task makes no sense. First of all, there's no "copy" operation on the OS level. Copy is a sequence of open/read/close (source) + create/write/close (dest) operations. Now, even if such operation existed (eg. Explorer has such concept), what about archiving the file and then copying out the archive?