How can I make TFS2010/VS2010 save one solution file with a given encoding? - visual-studio-2010

I have a batch file that executes during my build. Every time I check it in with changes, the file gets saved as UTF-8 (or UTF-16, hell I don't know), and thus gets a BOM. That makes it so that whenever the batch file is run, execution will fail because batch files have to be encoded as plain ASCII.
While it is simple to change the encoding on the file when I save it, I forget a lot of times.
Is there a way that I can get TFS or Visual Studio to ALWAYS save that one file in the proper format? (I know I can set VS up to always save all files as a certain type, but I was hoping I could make the change for just one file)

From within Source Control Explorer right-click the file you 're interested in & select 'Properties'.
On the 'General' tab there's the option to "Set Encoding". Check it out to see if you can find a suitable encoding to your purpose.

Related

CSV download is splitting into CSV and CSV.part

I'd like to download a CSV file from JupyterLab.
It's 66MB and it shows the file is downloading, but it's split into CSV and CSV.part.
According to JupyterLab, the download has finished but they haven't combined into a single CSV.
When I open the csv.part, it says there are no applications to open it.
When I open the csv, it's empty.
I've tried re-downloading and it's always the same.
What do I do here?
Whatever application you used to download the file - a web browser? Safari? Chrome? - downloads the data into a temporary file (with .part on the end) and it is supposed to rename it to myfile.csv after the download has completed.
For whatever reason, it has not done this last step.
Simply delete the empty file myfile.csv and rename myfile.csv.part to myfile.csv. You will see a warning ("Are you sure you want to rename this?") - yes. You are sure.
There is nothing magical about file name extensions, except of course that they tell MacOS which application to open the file with. They should also give you a clear indication of what sort of data is in the file, but this is not actually enforced by anything. If you rename a file to something inappropriate for the content (e.g. if you name your file "myfile.mp3"), it simply won't load into the application as the data isn't valid. But, there is nothing special about the .part file - the name is just supposed to indicate that the download (probably) hasn't finished yet. Except in this case, I assume you know that it has.
(This seems like a bug to me, perhaps with JupyterLab - but that's beside the point).

shortcut to files on network share whose name keep changing constantly

There is a network share used as repository in my company and it is quite difficult to navigate through it and find certain files. Some of these files get a new name every day , usually the date changes, which makes it impossible to create shortcuts to them. Usually these are excel or word files. Is there a way I can create a shortcut to that file even though the date has changed on the name of the file?
If you definitely have to use a shortcut (lnk file) for this the only workaround that comes to mind is pointing the shortcut to an environment variable and changing that programatically (wildcards are not supported in lnk files afaik).
However I assume that in most cases what you want is not really a shortcut in its technical definition but rather a way to open the file you want with a double click. In this case it would be a lot easier to just use a simple script that figures out what the name of the file currently is (by whatever rules you use manually) and launch it.
Should be doable in vbscript or powershell (maybe even batch) just fine as long as there is some logical way to determine which file is the right one (e.g. always the current date, always the file where the date is newest, the only file with extension xlsx, ...)

In DBF, "Ñ" character is showed as "¥"

I open a DBF file in Visual FoxPro and it shows "Ñ" character as "¥". I haven't created that DBF, I just open it and read it.
My question is: Is there any way to show those "¥" characters correctly in FoxPro? Or does it mean that this DBF file was created wrongly?
You probably need to know which encoding was used when the file was saved, depending on the version number of the file. Also the MSDN has a dedicated page about this topic. https://msdn.microsoft.com/en-US/library/5b10d8b6(v=vs.80).aspx
In specific the first paragraph might be for your interest:
When you create .dbf files, Visual FoxPro automatically gives them
code page marks so that you can tell which code pages they use.
However, if you use .dbf files from previous versions of FoxPro, they
might not have code page marks. You can determine whether a .dbf file
has a code page mark by using the CPDBF( ) function after opening the
file or by having Visual FoxPro check when you open the file.
You need to set the proper code page of your DBF file.
To know it, open the file with DBF Commander Pro, click 'Tools -> Set Codepage', then try to set the proper encoding by choosing various encodings from the list (leave 'Preview' check box turned on):
The program has 30-day fully functional trial period, so you can do your task at no charge.

How is "Cut" command in Windows executed globally and why data recovery is not possible?

So, I wondered several times, what's the actual low-level difference when using "Cut" command in Windows, apart from Copy-Paste-Delete one, with focus being on the "Delete" part.
However, until now it wasn't really important, but I had some issues recently when using Cut-Paste in my application, when having an error in the process. The file that was being Cut-Pasted doesn't exist anymore, and can't be recovered by any data recovery software out there.
So I ran some tests, and it seems that it's true.
Anybody knows how the Cut-Paste commant works?
The clipboard
Windows manages an internal object called The Clipboard and provides an interface to put data in the clipboard, get the data from the clipboard, get meta information about the content of the clipboard (check if it is empty or there is any data there, get the type of the data a.s.o.). The operations with the clipboard (get, put) have copy semantics. They do not destroy the source data. The object currently kept in the clipboard can be get from there any time you want, it is not removed after the first "get" operation.
The clipboard can store a single object at any time. When an application puts something in the clipboard the previous content of the clipboard is lost. The clipboard can store the same data in multiple formats; is the application's responsibility to put it there in multiple formats, to query about the available formats and get the data in the format it wants. For example, an HTML-editor can put in the clipboard both the HTML source code of the selected text and the text as it is rendered in the browser (with different colors and fonts etc). Then, the same application or another application either gets the needed format depending on the context or provides a "Paste Special" command where it asks the user what format to use (see Microsoft Office programs or OpenOffice programs for example).
The clipboard is available (through the operations provided by Windows) to all the applications that want to use it and it is a powerful method to transfer data between applications. However, due to different formats used by different applications, it is not always possible to get data from an application and put it into another one. For example, a plain text editor like Notepad cannot Paste an image previously put in the clipboard by Paint, Photoshop or another graphic editor. This happens because Notepad just don't know how to handle anything but plain text.
The Cut, Copy and Paste semantic for applications that handle content (text, images etc)
It's up to each application how they use the clipboard. Implementing the Cut, Copy and Paste operations usually means:
Cut - the application puts (copies) to the clipboard the object selected in the document then remove it from the document;
Copy - the application puts (copies) to the clipboard the object selected in the document (but it does not remove it from the document);
Paste - the application gets (copies) from the clipboard the object stored there and puts into the current document; depending on the application, it is either inserted at the position of the caret, or replaces the current selection or it is simply inserted into the current container (folder or directory, in Windows Explorer); the content of the clipboard is not changed; a subsequent Paste is possible and it will do the same;
The Cut, Copy and Paste semantic for applications that handle files (Windows Explorer, for example)
Windows Explorer and other programs that works with files and not with pieces of text or image use a different semantic. The biggest difference from the model above is that Windows Explorer works with file names (with full paths) and not with the content of those files. It does not reads the file and it does not place the content of the file in the clipboard.
Cut - Windows Explorer copies the full path of the file into the clipboard; it also sets an internal flag that says "the file whose path is in the clipboard is meant to be moved by the next Paste"; it uses this flag to be able to render the cut file dimmed in all its windows until the operation completes or is aborted; it does not move or remove the file at this point;
Copy - Windows Explorer copies the full path of the file into the clipboard; it does not touch the file itself; then it clears the flag that was set on the last Cut operation; the file that was previously cut (if any) is now rendered again using the same style as the other files (no dim, no nothing); in other words, a Copy cancels any previous Cut;
Paste - Windows Explorer gets the file path from the clipboard; it copies the file pointed by that path into the current directory; what it does after that depends on its internal flag for Cut operation; if the flag is set then the file was cut before (see Cut and Copy above) then it will remove the file from their original location and also the flag; otherwise (when the Cut flag is not set because the last operation was a Copy), it does not affect the original file in any way.
Remarks on Windows Explorer's behaviour
It's important to notice that Windows Explorer does not put the file content in the clipboard. If you use the Cut or Copy command in Explorer then you delete the file, it will not be able to Paste it in a different directory because the file does not exist any more and it cannot copy an object that does not exist.
Also, a file that was Cut in Windows Explorer cannot be Pasted multiple times in different directories because Explorer pairs the Cut with the first Paste (if there was no Copy in the meantime) and produces a move operations from them. After the Paste the Cut flag is removed and, even if it is not removed, there is no way to move the file again because it is not on the path stored in clipboard any more.
I'm not on Windows now (I didn't use Windows in the last 3 years) but as far as I remember, you can Copy a file once then Paste it several times; a Copy followed by a Paste produces a copy of the file and as long as the source is still there, subsequent Paste operations can produce more copies.
Sure, an error that happens on the most inconvenient moment can produce data loss. Due to the way Windows Explorer handles the files and the errors that might happen, it is very unlikely that it accidentally removes a file during a Cut-Paste operation without putting it into the destination folder.
I'm absolutely confident that more files are lost due to human error than because of errors that happen during the execution of Windows Explorer.
Other applications
Other applications work in different ways. Most of those that deal with content (text, image, sound, video, etc) work as explained in the section about content. Most of those that deal with files work similar with Windows Explorer.
Another application can get the data that was put in the clipboard but Windows Explorer. It's up to that application to interpret it as plain text and put the file path it gets from clipboard into the current document as is (Notepad works this way) or recognize it is a file path and attempt to copy the file (or do something else with it). Another window or instance of Explorer does it, maybe other file managers do it too.
Multiple-clipboard applications
The programs from the Microsoft Office Suite (Word, Excel a.s.o) and also some other applications implement a multiple-clipboard feature. This functionality is not provided by Windows clipboard. These applications work with the clipboard as usual but the also keep a history of the objects they put into the clipboard in the past and offer the user a list of these objects for re-use. For compatibility and integration with other applications they also get from and put into the clipboard the object that the user selects for re-use. The Windows clipboard, however, still contains a single object, the last one that was put there by any application.

Redirect default program to another program when a file opens in Windows OS

This is only under windows env.
As I know windows os identifies associated application of a particular file by file extension.
Like wise each file (binary) starting with corresponding symbols ("starting symbols"). For an example .JPG starts with ÿØÿà. Let say I open this .JPG file in a Hex editor or a Text editor and then I change that starting symbols into another file type. for an example I can change ÿØÿà to .Eߣ (.mkv). So when I double click on the .JPG the Windows Photo Viewer says there are some errors or similar message. So I need to get some information about the application that tries to open that kind of a file. If I can, I need to open that file using the application that associated with "starting symbols".
Briefly when I open .JPG I need to open a default video player .mkv files. But It may not work for this example. Because I changed only the "starting symbols" of my .JPG.
Please give me any idea to do this.
Thanks!
When you encrypt the file, give it a new extension. e.g. Picture.jpg becomes Picture.encrypted-jpg. You then register as the handler for encrypted-jpg, decrypt the file, then launch the normal jpg handler.
When the shell is asked to perform a verb on a file, the shell does not use the contents of the file to determine which app to pass it to. The file extension is what determines how the file will be treated.
You wish to use the contents of the file to influence which app processes a shell verb. In order to do so you would need to create a launcher app that reads the file header and then decides which app to pass the file on to. You would assign your launcher app as the handler app for all file extensions that you were interested in.
Although you could do this, it would be much easier just to set the file extension appropriately.
The proper way to do this sort of thing is to replace the files with reparse points.
The downside is that this involves writing a file system filter driver, i.e., an operating system extension, which is a whole level of trouble above and beyond ordinary application programming. (Since Windows already does file encryption, I doubt it would be worth the effort.)

Resources