Image Compression: We have 2 different servers on the same network Server A has document folder where all the documents are saved. Server B has the code which tries to access the documents on Server A and then compress it.
This is where I am running into issues. Error at this line: using (WebClient webClient = new WebClient()) System.NullReferenceException: Object reference not set to an instance of an object.
UNC path given for the file to be accessed across servers:
\\ServerName\E$\ClientFiles\SHAH\SHAH_103696_20220531160805_2600.jpg
Any suggestions if the path is correct or If I have to change the path? Here is the method:
public void ImageCompressionStream(ShahImages fileImage)
{
try
{
using (WebClient webClient = new WebClient())
{
byte[] data = webClient.DownloadData(fileImage.filePath);
using (MemoryStream mem = new MemoryStream(data))
{
using (var yourImage = Image.FromStream(mem))
{
yourImage.Save(fileImage.filePath, ImageFormat.Jpeg);
}
}
}
}
catch (Exception ex)
{
}
}
enter code here