filenames

How do I ensure C#'s Process.Start will expand environment variables?

泪湿孤枕 提交于 2020-01-24 02:25:28
问题 I'm attempting to create a process like so: var psi = new ProcessStartInfo { FileName = @"%red_root%\bin\texturepreviewer.exe", UseShellExecute = true }; var process = Process.Start(psi); process.WaitForExit(); Now the environment variable "red_root" definitely exists in the spawned process' environment variables, but the execute doesn't seem to expand the environment variable and so the file isn't found. How can I get the Process.Start to expand the environment variable in the file name? 回答1

check for duplicate filename when copying files in C#

那年仲夏 提交于 2020-01-24 01:46:06
问题 I want to copy files to a directory and rename to a particular format. but if the filename already exists, it should append {1}, {2} or {3} before the file extension. My code renamed and copied the file and named it to my desired format say filename.pdf, when it checked for duplicate it renamed it to filename1.pdf. but when it tried copying again, it gave an error "file already exists" but i wanted it to have named it to filename02.pdf. Pls can someone help me out. Here is the code i have

best way to remove file extension [duplicate]

ぐ巨炮叔叔 提交于 2020-01-22 13:09:19
问题 This question already has answers here : How to get filename without extension from file path in Ruby (9 answers) Closed 5 years ago . What is the shortest way to remove file extension? this is what I have tried: file = "/home/usr/my_file.xml" file = File.basename(file) file.slice! File.extname(file) #=> my_file 回答1: Read the documentation of File::basename : basename(file_name [, suffix] ) → base_name Returns the last component of the filename given in file_name, which can be formed using

best way to remove file extension [duplicate]

非 Y 不嫁゛ 提交于 2020-01-22 13:09:05
问题 This question already has answers here : How to get filename without extension from file path in Ruby (9 answers) Closed 5 years ago . What is the shortest way to remove file extension? this is what I have tried: file = "/home/usr/my_file.xml" file = File.basename(file) file.slice! File.extname(file) #=> my_file 回答1: Read the documentation of File::basename : basename(file_name [, suffix] ) → base_name Returns the last component of the filename given in file_name, which can be formed using

Method to inspect first 4 bytes and rename file extension

╄→гoц情女王★ 提交于 2020-01-15 09:08:47
问题 I have a large batch of assorted files, all missing their file extension. I'm currently using Windows 7 Pro. I am able to "open with" and experiment to determine what application opens these files, and rename manually to suit. However I would like some method to identify the correct file type (typically PDF, others include JPG, HTML, DOC, XLS and PPT), and batch rename to add the appropriate file extension. I am able to open some files with notepad and review the first four bytes, which in

how to give pdfData a filename for user to save swift

╄→гoц情女王★ 提交于 2020-01-15 07:07:49
问题 I give my pdfData to user to save. He can save to files and make a file, but the default name of the pdf file is: PDF document.pdf. I want my own filename if this is possible. Perhaps I can change the filename within the pdfData before I give pdfData to UIActivityViewController? Here is my code // Create page rect let pageRect = CGRect(x: 0, y: 0, width: 595.28, height: 841.89) // A4, 72 dpi // Create PDF context and draw let pdfData = NSMutableData() UIGraphicsBeginPDFContextToData(pdfData,

How to get the pagename from the URL without the extension through JQuery

风格不统一 提交于 2020-01-14 22:52:46
问题 I have a URL:- http://www.example.com/keyword/category.php or http://www.example.com/keyword/category.php#4 I need a magic abracadabra which gives me only the pagename as category from this URL. Here is what I tried, and it gives category.php . But it has two problems. It is ugly and long and it gives me filename with an extension. var currurl = window.location.pathname; var index = currurl.lastIndexOf("/") + 1; var filename = currurl.substr(index); Thanks. 回答1: Just make this into a function

How to get the pagename from the URL without the extension through JQuery

↘锁芯ラ 提交于 2020-01-14 22:50:29
问题 I have a URL:- http://www.example.com/keyword/category.php or http://www.example.com/keyword/category.php#4 I need a magic abracadabra which gives me only the pagename as category from this URL. Here is what I tried, and it gives category.php . But it has two problems. It is ugly and long and it gives me filename with an extension. var currurl = window.location.pathname; var index = currurl.lastIndexOf("/") + 1; var filename = currurl.substr(index); Thanks. 回答1: Just make this into a function

Get filenames using glob

守給你的承諾、 提交于 2020-01-14 19:15:39
问题 I am reading several tsd files using panda and combine them to a big frame. I am using glob to iterate trough all the files in my directory and sub-directories. Every single frame gets a unique key. Now I want to create a reference table where the file name to each key is stored. But since I don't really understand glob I don't know how to get only the names of the files. p = Path('myPath') data = [] reference_table = {} number_of_files = 0 for tsd_files in p.glob('**/*.tsd'): data.append(pd

Get filenames using glob

ε祈祈猫儿з 提交于 2020-01-14 19:11:08
问题 I am reading several tsd files using panda and combine them to a big frame. I am using glob to iterate trough all the files in my directory and sub-directories. Every single frame gets a unique key. Now I want to create a reference table where the file name to each key is stored. But since I don't really understand glob I don't know how to get only the names of the files. p = Path('myPath') data = [] reference_table = {} number_of_files = 0 for tsd_files in p.glob('**/*.tsd'): data.append(pd