본문 바로가기

C#(CSharp)71

Single Global Mutex I want to make sure this is out there, because it's so hard to get right: using System.Runtime.InteropServices; //GuidAttribute using System.Reflection; //Assembly using System.Threading; //Mutex using System.Security.AccessControl; //MutexAccessRule using System.Security.Principal; //SecurityIdentifier static void Main(string[] args) { // get application GUID as defined in AssemblyInfo.cs strin.. 2019. 6. 25.
Easily write a whole class instance to XML File and read back in Code snippet to serialize your garage to file could look like:var garage = new theGarage(); // TODO init your garage.. XmlSerializer xs = new XmlSerializer(typeof(theGarage)); TextWriter tw = new StreamWriter(@"c:\temp\garage.xml"); xs.Serialize(tw, garage);And code to load garage from file:using(var sr = new StreamReader(@"c:\temp\garage.xml")) { garage = (theGarage)xs.Deserialize(sr); } SOURCE.. 2018. 6. 25.
IOException: The process cannot access the file 'file path' because it is being used by another process private const int NumberOfRetries = 3; private const int DelayOnRetry = 1000; for (int i=1; i 2018. 6. 23.
Image read stream memory in WPF. using System;using System.Collections.Generic;using System.IO;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Media;using System.Windows.Media.Imaging; namespace gNcImgMover{ public class Utils { public static byte[] ConvertBitmapSourceToByteArray( BitmapEncoder encoder, ImageSource imageSource ) { byte[] bytes = null; var bitmapSource = imageSource as Bitma.. 2018. 6. 23.