Landei00 Landei00 - 17 days ago 9
C# Question

How to make file path in required format?

I want to compare to images and have to make them first as a Bitmap.

Bitmap bmp1 = new Bitmap(file1);


file1 contains the path as a string in the following format:

C:\anyfile.jpg


But C# need to convert this in the following format:

C:\\anyfile.jpg


Is there any possibility to convert the string to the needed format?

Answer

One way would be:

file1 = file1.Replace(@"\", @"\\");