file-extension

ASP.NET MVC - Routing - an action with file extension

喜你入骨 提交于 2019-11-27 09:01:20
is there a way to achieve calling URL http://mywebsite/myarea/mycontroller/myaction.xml This would basically "fake" requesting a file but the result would be an action operation that would serve a file created dynamically? I tried this: context.MapRoute( "Xml_filename", "Xml/{controller}/{action}.xml" ); but whenever there is a filextension in the URL the routing fails and behaves as I was requesting a file directly. I suspect this might be because of using extension less url handler. <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH

Changing file extension in Python

*爱你&永不变心* 提交于 2019-11-27 08:11:02
Suppose from index.py with CGI, I have post file foo.fasta to display file. I want to change foo.fasta 's file extension to be foo.aln in display file. How can I do it? Ignacio Vazquez-Abrams os.path.splitext() , os.rename() for example: # renamee is the file getting renamed, pre is the part of file name before extension and ext is current extension pre, ext = os.path.splitext(renamee) os.rename(renamee, pre + new_extension) FryDay import os thisFile = "mysequence.fasta" base = os.path.splitext(thisFile)[0] os.rename(thisFile, base + ".aln") Where thisFile = the absolute path of the file you

Where does Windows store its “Open With” settings?

白昼怎懂夜的黑 提交于 2019-11-27 08:01:08
I'm trying to programmatically check file associations by the file extension (for example .jnlp files). I keep reading that HKEY_LOCAL_MACHINE\SOFTWARE\Classes\JNLPFile\Shell\Open\Command is the Registry key to check. However, if you change the association through Windows Explorer: Open With > Choose Program > (Always use the selected program) the change isn't at all reflected in this Registry key. Where else is this information stored? Take a look in: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\ and the sub-key of that is the extension you reassigned. Under

How do you check a file type when there is no extension in c#

≯℡__Kan透↙ 提交于 2019-11-27 07:11:21
问题 How do you check a file type when there is no extension in c# For instance, I have files with no extension, that are either .mp4 or .flv format (just no extension). I plan on converting these video files to audio files however I would like to determine the file type before I start converting it. Is there a way to do this in C#? I was thinking that maybe I could just rename the file to name.mp4, then perform some task on the file that would either A) succeed, meaning that the file was indeed

Associate file extension to python script, so that I can open the file by double click, in windows

倖福魔咒の 提交于 2019-11-27 06:52:40
问题 I want to do the following: Save numeric data in a CSV-like formatting, with a ".foo" extension; Associate the ".foo" file extension with some python script, which in turns opens the .foo file, reads its content, and plots something with a plotting library (matplotlib most probably). The use-case would be: double-click the file, and its respective plot pops up right away. I wonder how I should write a python script in order to do that. Besides, the windows "open with" dialog only allows me to

List of ALL MimeTypes on the Planet, mapped to File Extensions? [closed]

烈酒焚心 提交于 2019-11-27 06:31:59
Is there a resource that lists ALL the mimeTypes in existence? I have found a few places with under 1000 mimeTypes, but then they still don't include common ones like .rar, .fla, .rb, .docx! Does anyone have a COMPLETE list of mimetypes? Not down to the most obsure "company-only" ones, but at least all of the ones we might use. Also, I'm looking for a list that maps file extensions to mimeTypes. http://www.iana.org/assignments/media-types/ lists the "official" mime-types, but it doesn't prevent anyone making their own an not registering it with IANA. Here's the most up-to-date mime.types

How to get file extension from string in C++

穿精又带淫゛_ 提交于 2019-11-27 06:31:37
Given a string "filename.conf" , how to I verify the extension part? I need a cross platform solution. You have to make sure you take care of file names with more then one dot. example: c:\.directoryname\file.name.with.too.many.dots.ext would not be handled correctly by strchr or find. My favorite would be the boost filesystem library that have an extension(path) function brian newman Is this too simple of a solution? #include <iostream> #include <string> int main() { std::string fn = "filename.conf"; if(fn.substr(fn.find_last_of(".") + 1) == "conf") { std::cout << "Yes..." << std::endl; }

Apache2 server mime types

心不动则不痛 提交于 2019-11-27 06:17:41
问题 I am trying to get my Apache2 web application to push an arbitrary file extension as an octet-stream when pointed to by a browser. i.e. Someone goes to blahblah/examples/example1.xyz I want the browser to download the .xyz file rather than just display it. I have tried adding .htaccess in the root of the web app including AddType application/octet-stream xyz And I have also tried to add the mime type to /etc/apache2/mods-enabled/mime.conf and /etc/mime.types which is referenced as the types

How can I find all of the distinct file extensions in a folder hierarchy?

吃可爱长大的小学妹 提交于 2019-11-27 05:45:47
On a Linux machine I would like to traverse a folder hierarchy and get a list of all of the distinct file extensions within it. What would be the best way to achieve this from a shell? Try this (not sure if it's the best way, but it works): find . -type f | perl -ne 'print $1 if m/\.([^.\/]+)$/' | sort -u It work as following: Find all files from current folder Prints extension of files if any Make a unique sorted list No need for the pipe to sort , awk can do it all: find . -type f | awk -F. '!a[$NF]++{print $NF}' ChristopheD Recursive version: find . -type f | sed -e 's/.*\.//' | sed -e 's/.

What's the difference between .lib and .a files?

雨燕双飞 提交于 2019-11-27 05:11:31
问题 I'm trying to statically compile something and I'm trying to get a handle on what all these dependencies are. I know that .dll files are for dynamically linked dependencies that will be required by the final output, but what are .a and .lib files and when do you need each of those? 回答1: .a is an archive of code: compiled but not linked. You would link statically with it during your program's final link step. .lib can be either the same as .a, or a magical so-called "import library": a thin