renaming a file in disk through web application
-
yesterday Mr.John sir has helped me in one issue which is related to the same task code--- else if (txtHospitalName.Text== "Medb" || txtHospitalName.Text== "Medw") { FileInfo thefile1 = new FileInfo(Server.MapPath("RtfFilesPath") + "\\voice\\" + txtOriginalName.Text.Trim() + ".wav"); if (thefile1.Exists) { File.Copy(Server.MapPath("RtfFilesPath") + "\\voice\\" + txtOriginalName.Text.Trim() + ".wav", Server.MapPath("RtfFilesPath") + "\\voice\\" + txtFilename.Text.Trim() + thefile1.Extension); GetData(); } hello frns the above is the snippet of code i used in my application what i am doing is copying a file and saving it with the someother name its working fine, but the actual problem is i'll be having two types of files in my folder one is .mp3 and .wav . so in the above code i am checking only the .wav file note: i'll be entering only the name of the file without extension, there may be any one of the two filetypes. what are the modifications/additions i have to make in my code to check for two types of file extensions thanks for ur replies in advance
-
yesterday Mr.John sir has helped me in one issue which is related to the same task code--- else if (txtHospitalName.Text== "Medb" || txtHospitalName.Text== "Medw") { FileInfo thefile1 = new FileInfo(Server.MapPath("RtfFilesPath") + "\\voice\\" + txtOriginalName.Text.Trim() + ".wav"); if (thefile1.Exists) { File.Copy(Server.MapPath("RtfFilesPath") + "\\voice\\" + txtOriginalName.Text.Trim() + ".wav", Server.MapPath("RtfFilesPath") + "\\voice\\" + txtFilename.Text.Trim() + thefile1.Extension); GetData(); } hello frns the above is the snippet of code i used in my application what i am doing is copying a file and saving it with the someother name its working fine, but the actual problem is i'll be having two types of files in my folder one is .mp3 and .wav . so in the above code i am checking only the .wav file note: i'll be entering only the name of the file without extension, there may be any one of the two filetypes. what are the modifications/additions i have to make in my code to check for two types of file extensions thanks for ur replies in advance
sunilwise wrote:
FileInfo thefile1 = new FileInfo(Server.MapPath("RtfFilesPath") + "\\voice\\" + txtOriginalName.Text.Trim() + ".wav"); if (thefile1.Exists) { File.Copy(Server.MapPath("RtfFilesPath") + "\\voice\\" + txtOriginalName.Text.Trim() + ".wav", Server.MapPath("RtfFilesPath") + "\\voice\\" + txtFilename.Text.Trim() + thefile1.Extension); GetData(); }
FileInfo thefile1 = new FileInfo(Server.MapPath("RtfFilesPath") + "\\voice\\" + txtOriginalName.Text.Trim() + ".wav"); if (!thefile1.Exists){ thefile1 = new FileInfo(Server.MapPath("RtfFilesPath") + "\\voice\\" + txtOriginalName.Text.Trim() + ".mp3"); } if (thefile1.Exists) { File.Copy(Server.MapPath("RtfFilesPath") + "\\voice\\" + txtOriginalName.Text.Trim() + ".wav", Server.MapPath("RtfFilesPath") + "\\voice\\" + txtFilename.Text.Trim() + thefile1.Extension); GetData(); }
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) "Please vote to let me (and others) know if this answer helped you or not. A 5 vote tells people that your question has been answered successfully and that I've pitched it at just the right level. Thanks."
-
sunilwise wrote:
FileInfo thefile1 = new FileInfo(Server.MapPath("RtfFilesPath") + "\\voice\\" + txtOriginalName.Text.Trim() + ".wav"); if (thefile1.Exists) { File.Copy(Server.MapPath("RtfFilesPath") + "\\voice\\" + txtOriginalName.Text.Trim() + ".wav", Server.MapPath("RtfFilesPath") + "\\voice\\" + txtFilename.Text.Trim() + thefile1.Extension); GetData(); }
FileInfo thefile1 = new FileInfo(Server.MapPath("RtfFilesPath") + "\\voice\\" + txtOriginalName.Text.Trim() + ".wav"); if (!thefile1.Exists){ thefile1 = new FileInfo(Server.MapPath("RtfFilesPath") + "\\voice\\" + txtOriginalName.Text.Trim() + ".mp3"); } if (thefile1.Exists) { File.Copy(Server.MapPath("RtfFilesPath") + "\\voice\\" + txtOriginalName.Text.Trim() + ".wav", Server.MapPath("RtfFilesPath") + "\\voice\\" + txtFilename.Text.Trim() + thefile1.Extension); GetData(); }
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) "Please vote to let me (and others) know if this answer helped you or not. A 5 vote tells people that your question has been answered successfully and that I've pitched it at just the right level. Thanks."
thanks for u r answers sir its working fine :):):):cool: