system.io.file

picture is used by another process (layoutpanel)

你。 提交于 2019-12-11 16:04:54
问题 So i am filling a float layout panel with images, with this code: private void FillPanel(string sql) { panel.Controls.Clear(); SQLiteConnection dbConnect = new SQLiteConnection("Data Source=" + dbFullPath + ";Version=3;"); dbConnect.Open(); SQLiteCommand runQuery = new SQLiteCommand(sql, dbConnect); SQLiteDataReader reader = runQuery.ExecuteReader(); while (reader.Read()) { PictureBox pB = new PictureBox(); pB.Image = Image.FromFile(reader["imgPath"].ToString()); pB.Size = new Size(100, 100);

The process cannot access the file '…' because it is being used by another process

人走茶凉 提交于 2019-12-11 15:46:05
问题 I have a code to delete file in my folder, but in my line code, I want to delete two file together with different folder. But I always get an error "the process cannot access.... another process". May be you can correct my code and give me a solution. Thanks 1) I have a code to generate watermark when save file(.pdf): public bool InsertWaterMark(string path) { bool valid = true; string FileDestination = AppDomain.CurrentDomain.BaseDirectory + "Content/" + path; string FileOriginal = AppDomain

FileSystemSafeWatcher Missing Files Copied

筅森魡賤 提交于 2019-12-11 15:28:23
问题 I'm currently using FileSystemSafeWatcher to overcome issues caused by File System Watcher. (Ref:Is there a simple way to avoid or stop FileSystemWatcher raise event twice in C#?) When trying to monitor a folder for copied event of around approx 400 images,Only approx 300 events are triggered.Files can be downloaded from https://drive.google.com/file/d/1bcmQw4P79p9FCS2E0k_UKr5hKiQLZCgQ/view?usp=sharing I cannot understand what causes this issue. Copied event void copied(object sender,

Does the .net framework provides async methods for working with the file-system?

五迷三道 提交于 2019-11-30 06:23:54
Does the .net framework has an async built-in library/assembly which allows to work with the file system (e.g. File.ReadAllBytes , File.WriteAllBytes )? Or do I have to write my own library using the async Methods of StreamReader and StreamWriter ? Something like this would be pretty nice: var bytes = await File.ReadAllBytes("my-file.whatever"); Does the .net framework has an async built-in library/assembly which allows to work with the file system Yes. There are async methods for working with the file system but not for the helper methods on the static File type. They are on FileStream . So,

Does the .net framework provides async methods for working with the file-system?

瘦欲@ 提交于 2019-11-29 05:08:17
问题 Does the .net framework has an async built-in library/assembly which allows to work with the file system (e.g. File.ReadAllBytes , File.WriteAllBytes )? Or do I have to write my own library using the async Methods of StreamReader and StreamWriter ? Something like this would be pretty nice: var bytes = await File.ReadAllBytes("my-file.whatever"); 回答1: Does the .net framework has an async built-in library/assembly which allows to work with the file system Yes. There are async methods for

How to WriteAllLines in C# without CRLF

半腔热情 提交于 2019-11-28 10:59:26
I'm using C# and am trying to output a few lines to an ASCII file. The issue I'm having is that my Linux host is seeing these files as: ASCII text, with CRLF line terminators I need this file to be just: ASCII text The CRLF is causing some issues and I was hoping there was a way in C# to just create the file formatted in the way I want. I'm basically using this code: string[] lines = { "Line1", "Line2" }; File.WriteAllLines(myOutputFile, lines, System.Text.Encoding.UTF8); Is there an easy way to create the file without the CRLF line terminators? I can probably take care of it on the Linux side

Fastest way to copy files from one directory to another

天大地大妈咪最大 提交于 2019-11-27 06:30:10
问题 I need to copy files from one directory to another, depending on the existence of the file name in a table of SQL database. For this I use the following code: using(SqlConnection connection = new SqlConnection("datasource or route")) { connection.Open(); using(SqlCommand cmd = new SqlCommand("SELECT idPic, namePicFile FROM DocPicFiles", connection)) using (SqlDataReader reader = cmd.ExecuteReader()) { if (reader != null) { while (reader.Read()) { //picList IS AN ARRAY THAT Contains All the