How to read embedded resource text file

You can use the Assembly.GetManifestResourceStream Method: Add the following usings using System.IO; using System.Reflection; Set property of relevant file: Parameter Build Action with value Embedded Resource Use the following code var assembly = Assembly.GetExecutingAssembly(); var resourceName = “MyCompany.MyProduct.MyFile.txt”; using (Stream stream = assembly.GetManifestResourceStream(resourceName)) using (StreamReader reader = new StreamReader(stream)) { string result = reader.ReadToEnd(); } … Read more

Upload files with HTTPWebrequest (multipart/form-data)

Took the code above and fixed because it throws Internal Server Error 500. There are some problems with \r\n badly positioned and spaces etc. Applied the refactoring with memory stream, writing directly to the request stream. Here is the result: public static void HttpUploadFile(string url, string file, string paramName, string contentType, NameValueCollection nvc) { log.Debug(string.Format(“Uploading … Read more

Converting String^ to Int

Standard ‘learning the language’ warning: This isn’t C++ you’re writing, it’s C++/CLI. C++/CLI is a language from Microsoft intended to allow C# or other .Net languages to interface with unmanaged C++. In that scenario, C++/CLI can provide the translation between the two. If you’re still learning C++, please do not start with C++/CLI. In order … Read more