Skip to main content

Getting error in sending MMS:

IOException: The process cannot access the file 'C:UsersDELLSourceReposCosmeticsOmsOms.WebwwwrootfilesRingCentral est_4e28.jpg' because it is being used by another process.

MY CODE:

var attachment = new Attachment { fileName = model.FileName, contentType = imageType, bytes = System.IO.File.ReadAllBytes(filePathCopy) };

Seems the file is being open by another program in your computer. This may have nothing to do with the SDK or the API. Double check it and try.


Thanks for reply I just upload file into folder then access file into attachment.

var imageType = "";

if (model.UploadedFile != null)

{

var directoryPath = Path.Combine(_env.WebRootPath, localDirectoryPath);

var uniqueFileName = GetUniqueFileName(model.UploadedFile.FileName);

imageType = model.UploadedFile.ContentType;


var filePath = Path.Combine(directoryPath, uniqueFileName);

model.UploadedFile.CopyTo(new FileStream(filePath, FileMode.Create));

model.FileName = uniqueFileName;

model.FilePath = localDirectoryPath + model.FileName;

}


var parameters = new CreateSMSMessage();

parameters.from = new MessageStoreCallerInfoRequest { phoneNumber = ringCentralCredentials.Username };

parameters.to = new MessageStoreCallerInfoRequest[] { new MessageStoreCallerInfoRequest { phoneNumber = model.ReceiptNumber } };

parameters.text = model.Message;

var filePathCopy = "wwwroot/" + model.FilePath;

var attachment = new Attachment { fileName = model.FileName, contentType = imageType, bytes = System.IO.File.ReadAllBytes(filePathCopy) };


Reply