MATLAB: How to show path of file in GUI editbox

uigetfile

Hello All, I am facing an issue with uigetfile. What I have is a button "Upload" along with a edit box which supposed to be showing the path of the uploaded file. Here is what I tried:
%--- Executes on button press in upload.
function upload_Callback(hObject, eventdata, handles)
% hObject handle to upload (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[FileName1,PathName1] = uigetfile({'*.txt';'*.csv';'*.*'},'Select the text file that contains the data');
if isempty(FileName1)
errordlg('No file was selected that contains the data so the calculation was aborted.');
flag = true;
return
end
% text file should consist of two columns,
fid = fopen(fullfile(PathName1,FileName1));
if fid == -1
errordlg('The file selected could not be read so the calculation was aborted.');
flag = true;
return
end
d = textscan(fid,'%f %f');
fclose(fid);
S3.fValues = d{1} % data1
S3.rValues = d{2} % data2
S3.selected_dir_upload =[Pathname1,FileName1];
handles.S3.selected_dir_upload =S3.selected_dir_upload ;
guidata(hObject, handles);
set(handles.upload_edit, 'String', S3.selected_dir_upload)
set(handles.upload, 'UserData', S3);
I am not able to set the path in edit box. Your help is much appreciated.

Best Answer

S3.selected_dir_upload = fullfile(Pathname1, FileName1);