Copying and Pasting Binary Creates a Useless File - executable

Why is it that when copying the content of a file such as an audio file (mp3) and pasting it in a newly created mp3 the new one does not execute?
I open file 1 (which executes and works just fine):
copy its contents, and then paste it in a newly created mp3 file, yet the new one does not execute. Why is that and how can I fix it?

Related

How to copy a file without extension and at the end of the copy put it?

I am using teracopy to move some files. I would like to make a form in visual * .exe where you simply have two windows: one with the file's origin on the right, and another with the file's destination.
I need to copy the file without its extension, verify that the transfer occurred without issue, and then restore the original extension. For example:
Copy file.mov to // smb: Storage / Movies /
Remove the .mov extension
Copy the file to the storage location
Validate file size
If the file size at the destination matches the source, restore the .mov extension
If the file size doesn't match, delete the destination file and notify the user of the error.
The files I plan to copy are very large, and will take a good amount of time. I'm removing the extension so that users on the server will not accidentally try to access a file that isn't completely transferred yet - the idea is they see an "extensionless" file and know not to try and open it, whereas any files with extensions are certain to have copied over correctly.
I've tried using CMD and powershell, but I've only managed to copy the file or retry copying if the copy fails. I don't yet know how to remove the extension and restore it.
> ROBOCOPY /Mir <Source> <Target>
You can try this:
copy %UserProfile%\YourFile.* "Path to copy to"

Reopen DOC file in write mode, with macro inside it

I am using a macro template for particular DOC files only. It runs only for these files and, as I assume, it is treated as the DOC file itself.
All I want is to remove the file OR clear the contents of it, after the macro finishes. The initial file is read-only.
I have tried:
SavingAs in TEMP folder, change file attribute of initial file and then try to Kill it - no luck, it seems that initial file is still preloaded(?) and does not know that the read-only flag was removed. Error: Permision denied.
When I try to Close the initial document, I am closing also the macro itself...
So:
Is there any way to (from the macro inside the DOC file) :
Reopen the file in write-mode? (so I could clear the contents afterwards)
Remove the initial file? (after SaveAs so I actually will have a new file in write-mode and will be able to remove initial file)

Why are EXCEL XLSM format no longer a valid ZIP format?

Files saved in Excel as XLSM files are no longer valid ZIP files, preventing editing of the Ribbon.
XLSM files saved on or prior to May 23, 2014, can be renamed .ZIP and edited.
XLSM files saved after May 23, 2014, cannot be renamed .ZIP and edited, but rather generate the error message that the file is a corrupted archive. Both Windows Explorer and WinZip generate the same error condition, though the error message varies slightly.
Yes, there are macros in the files; but even opening an old file with Macros (and VBA) disabled and immediately Saving As a new name generates a corrupted file.
I have also tested on 2 other machines in our corporate group, with the same results, so it is not a corruption just on my workstation.
Office Diagnostics reports no problems with EXCEL.
Any thoughts on causes or solutions?
Update
Let's be clear on my test process:
I rename an XLSM file saved on May 23 to .ZIP; this creates a zipped archive which both WinZip and Windows Explorer can open successfully. I then undo the rename to make the file an XLSM again.
I open the file above in EXCEL-2007 and do not enable macros or VBA. I save this with a new filename as an XLSM file.
I rename the file saved in step (2) as a .ZIP file. This file no longer opens in either WinZip or Windows Explorer, but generates the error message above.
I repeat steps 1 through 3 above on the workstations of two other colleagues - same result exactly.
Update #2
The problem seems to be file-related in some way, as saving an empty workbook as an XLSM still works. I will investigate more.
The problem is that one or more of the sheets are password protected. Unprotect the sheets, then save as xlsm, rename to .zip and voila, XML structure now appears.
Update:
Actually, it was an inconsistent setting of password-protection for the workbook rather than any worksheet.

Programmatical and application-based editing of an Excel file

Good evening,
I have the following problem to solve:
I want to add to an Excel file the contents of a bunch of user-generated .txt files. These files are generated throughout the day and sent over FTP to a folder, which is being constantly monitored by the program to see if there are new additions.
If the program finds new .txt files in it, it opens the Excel file which is to be edited, adds the info and then closes the Excel, saving the changes.
At the same time, users have to open these Excel files to check the new updated info and deal with it accordingly.
The program's execution is somewhat like this:
Infinite loop checking if the folder is empty or contains new .txt files.
If the folder is not empty (hence there is info to be added), it checks whether the Excel file is open or not.
If the Excel file is closed:
Opens it programmatically and adds the info to it.
Saves the Excel file and quits.
Backups the .txt to another folder in case there was some sort of error.
If the Excel file is open:
Keep checking until it is closed.
To check if the folder is empty or not I use: System.IO.Directory.EnumerateFileSystemEntries(path).Any()
To check if the Excel file is open I use:
System.IO.FileInfo(path) and a FileStream which, inside a Try-Catch clause, opens the FileInfo in the following mode: info.Open(FileMode.Open, FileAccess.ReadWrite, FileShare.None)
For the opening, editing and saving/closing of the Excel file I use Microsoft.Office.Interop.Excel.Application, [..].Workbook and [..].Worksheet.
The main problem comes when a user opens (through the normal Office Application) the Excel file in the middle of the addition process. I was hoping to find some sort of lockage of said file so the user cannot interrupt the editing process.
Any ideas on how to combine both types of opening/editing the Excel file?
Thank you so much in advanced.
TL;DR: How can I prevent, programmatically, a user from opening an Excel file while a program is editing that very Excel? Or at least, open another instance of it so the process is not interrupted?
PS: If any further code should be needed, I'll gladly post it :)
I think you need a better solution. It sounds like you are maxing out the capabilities of Excel. You would be better off, if possible, to use a database.

How to copy and paste a file with the clipboard from a compressed folder using VB.NET

How do I copy and paste a file with the clipboard from a compressed folder using VB.NET?
I want to paste a file from the clipboard that has been copied from a compress folder using VB.NET. By examining the clipboard, I see there is a FileGroupDescriptorW which seems to contain some information about the file. But how do I use the information to grab the file and paste it?
The clipboard should contain data in the format of CF_HDROP. This can be converted to a file list by calling the DragQueryFile API.
Then it's just a list of fully-qualified filenames of whatever files were copied, and now you can operate on those files. A Visual Basic example is in How To Obtain Files Copied from Windows Explorer.