MATLAB: How to solve the error

error

clc;
clear all;
close all;
I = dicomread('C:\Users\Click Me\Desktop\NIELIT\images output\try.dcm');
info = dicominfo('C:\Users\Click Me\Desktop\NIELIT\images output\try.dcm');
imshow(I,'DisplayRange',[]);
II = imread('rice.png');
info.PatientID = 'rice';
L = dicomwrite(I,'rice.dcm',info);
I was trying to insert rice.png image into dicom file. But I got this error:
Error using dicom_open_msg (line 31)
Could not open "rice.dcm" for writing
Error in dicomwrite>write_stream (line 659)
file = dicom_open_msg(file, 'w');
Error in dicomwrite>encodeAndWriteAttrs (line 324)
msg = write_stream(destination, data_stream);
Error in dicomwrite>write_message (line 281)
encodeAndWriteAttrs(attrs, options, filename);
Error in dicomwrite (line 208)
[status, options] = write_message(X, filename, map, metadata,
options);
Error in truuu (line 10)
L = dicomwrite(I,'rice.dcm',info);
How to solve this? How to insert a png image into a dicom file?

Best Answer

Could not open "rice.dcm" for writing
This can mean, that the file is write-protected or you do not have the permissions to write in this folder. Check this either in the file explorer of the operating system or by the fileattrib command.
This tries to create the file in the current folder:
dicomwrite(I,'rice.dcm',info)
Better define the folder to write to explicitly. fullfile might be useful here.