File Cannot Be Saved Because it is Write-Protected - vb.net

I am using Visual Web Developer 2010 Express and I just added my files into Visual SourceSafe. When I try to save files in Visual Web Developer, it says, "The file cannot be saved because it is write-protected." It gives me the option to overwrite, but I don't know if that's how it's supposed to work. Ideally, I will click save and it will save the various versions into source safe. I've never used source safe before; my previous source-control system just enabled be to click "commit."

Files under source control are marked as read-only to prevent accidental changes to files and only made writeable when you check them out for editing.
Because there is no source control integration with the Visual Studio Express 2010 editions when you make an edit the file is not automatically checked out from source control so it remains read-only, thus causing the problem you have here.
You either need to check out the files before editing the project or force an overwrite and then check out the file after the event. Neither of which is an ideal solution.

When you add items to source control, such a Source Safe, it marks them as Read Only to ensure they are not written by anyone who has not checked-out the files.
You need to check-out the file you wish to edit, then edit it, save it, then check it back in.
Source Safe is rather old and not really maintained by Microsoft anymore - consider using something more modern like Subversion or Git.

Related

Finding origin extension

I'm just starting my adventure with programming and VBA and now I have small problem. Sometimes people change extension of files (they have some reasons) but I need to find extension before changing.
For example: first it was doc , then docm, then odt (or pdf, etc.) and I need to find that it was doc at the beginning. I don't know if it's possible.
I thought that if I open file in notepad there is some kind of code in it, and probably part of code may be "origin" extension, but which part is it? Or is there some other way I could use in VBA?
Please Look into #Tim Williams comments, it is not prudent to try to find origin's extension as many a times files are saved in different file formats. However various approaches for keeping track of file version and history of the files are mentioned here-under.
There are some tools(example-XLTools) and processes that will allow you to see the revisions of an Excel sheet. As far as a revision history within the Excel sheet, you will not have any unless you have set this up yourself. There is not a built in change history for Excel. Otherwise File History regularly backs up versions of your files in the Documents, Music, Pictures, Videos, and Desktop folders and the OneDrive files available offline on your PC. Over time, you'll have a complete history of your files. If the originals are lost, damaged, or deleted, you can restore them. You can also browse and restore different versions of your files. For example, if you want to restore an older version of a file (even if it wasn't deleted or lost), you can browse through a timeline, select the version you want, and restore it.
If your files are uploaded to SharePoint and If a list or library on your site tracks versions, you can view version history for items or files, providing you have Read permission to the list or library. The version history contains information about when the item or file was changed, who changed it, and information about what was changed. In libraries, the version history might also contain comments written by the people who made changes.
You can view version history in either of two ways:
In the list or library on your site
In the Microsoft Office Backstage view of a Microsoft Office 2010 document. You can also track changes if you upload to DropBox Or say Box, there also revision history and version changes can be tracked.

VbaProject.OTM deployment

I came by this page and was thinking about the best method to distribute my VbaProject.OTM file (located into %appdata%\Microsoft\Outlook\) to a bunch of ~30 users at my office. Is it better to simply copy/paste the OTM file onto the network and then copy/paste it back to all users' computers (manually or with a .bat) OR would it be better to use the method described in the link above to generate a OPS file and import it back with Proflwiz.exe? What's the difference?
We are all on Microsoft Office Outlook 2003 actually, we might upgrade to 2007 one day but still years from now.
Finally came up with some elements to deploy a Outlook VBA Project. There are a lot of ways to do this, but the easiest way to do so without installing anything and keeping the same methodology would be to run a OTM file directly from a server. I found out that the process outlook.exe has a parameter altvba that allows to specify another path to run the OTM file from. Here is en example:
outlook.exe /altvba "\\myServer\myFolder\myFile.otm"
This allows me to update only one file to get all computers updated. Obviously, if the file is big and the server's ping is on the high side, it may delay the launch of Outlook. The other problem with this method is that everybody will have to shut down Office if you want to update the OTM file on the server (and if you do work in an office where everyone uses Outlook, you do know that it is impossible to get everyone to shut it down at the same time, except if you code a macro to do so eventually). To prevent both those problems, I could setup a batch file to copy the server OTM file clientside everytime there is a new version (just have to check the NTFS last-modify attribute). This way, Outlook will boot with a local file, the batch file take 2-3 seconds to copy the file if needed (or will launch Outlook instantaneously) and there will be no problem updating the OTM file on the server. Users will have to start Outlook with the batch file (or with the slightly different outlook.exe path with the altvba parameter, so either way they need a different shortcut/file to start off the first time). One other advantage of the altvba is that it's still easy for the user to run Outlook without it (to see if the VBA is problematic or not in case Outlook is sluggish) and the file will remain unchanged after a Outlook reinitialization.
Others solutions include a COM complement that can be developed in a lot on languages including VB6 (no conversion needed from VBA). There is also a bunch of tools included into Microsoft Office XP Developer that could help getting the job done (not free however, especially if you need the most up-to-date version).

property promotion in infopath and sharepoint 2010

I have a SharePoint 2010 document library with >7000 xml documents created from infopath forms(Infopath 2007). Now i would like to promote few fields in the form to the SharePoint document library. I could do this only for documents created from the upgraded form, but not for all previously created documents. Although re submitting of old forms will work,It is not possible for me to update all 7000 records to promote the values to the column. Is there a much easier solution, considering the fact that this changes need to be implemented on a production environment too.
Note:The promoted columns will be used to generate graphical report. Any solution acceptable.
I've been through this before, and there's no good answer. If I understand correctly, you have existing InfoPath forms in a doc library, and you now want to promote fields to the document library, but you don't want to open each form one by one, correct?
Note, you most likely don't have to open then re-submit each form, you just have to open the form, and close it. Once you do that, the promoted fields will them show up.
So... what I've done before is this: First, get notepad++ (this allows you to open multiple files in tabs). Secondly, access the the doc library via WebDav (that is, go to the library in SharePoint, then go to the Library tab, and click Open with Explorer). Thirdly, open a large batch of files at once using notepad++ (select files, right-click, open with notepad++). It will take a moment for all the files to load in notepad++ in tabs. Once they are all open in notepad++, hit ctrl-w as fast as you can (which closes each file). Rinse and repeat.
It's not pretty, and I'm sure there's a better way to do this (programatically, perhaps), but this should work. At least you won't have to open each form one by one.
You can do this by relinking the document by powershell or through advanced settings.

Watch folder for files being Read

I am trying to watch files in a directory to determine when files are opened/accessed. I thought FileSystemWatcher would do the trick using the event Changed.
Problem is that some applications do not create a lock on the file they open/access or change either the date modified or date accessed (even after fsutil behavior set disablelastaccess 0). Notepad for example. Apparently is makes a copy of the file in memory and plays with it there until you save it. Nor does it update the Date Accessed.
How can I monitor a directory of files and be notified when a file is simply opened/accessed by any program (e.g. Notepad)? Files may be opened from another computer, not necessarily on the computer running the "watcher".
I found lots of similar questions but did not see one focusing on file "access".
This is quite normal. Updating an existing file is quite dangerous since it can cause irretrievable data loss. A disk error (like disk full) while writing is very bad news. The common algorithm used:
rename the original file
write a new file using the original name
no error: delete the renamed file
error: delete the new file, rename original file back
Clearly this doesn't cause a Changed event to be raised, no file was changed.
Sorry, I didn't read the question well enough. There is no notification whatsoever for an app just opening a file for reading. FSW can only detect changes to the file system. There is no ready alternative either, this requires a custom file system filter driver that snoops on driver requests. Like the kind that SysInternals' ProcMon utility uses. I'm not aware of such a driver ready for use in a C# program, you can't write them in C# either. This just isn't a common requirement.

Workspace.PendEdit not checking out files

I'm using the TFS 2010 SDK to programmatically check in edits to files into TFS 2010. The documentation on the TFS 2010 SDK is sparse at best. When I call the method workspace.pendedit() passing in an array of files I want to mark as having a pending edit, nothing is actually checked out. So when I call workspace.checkin() passing in workspace.getpendingchanges and some comments I get an exception that there must be at least one thing that has a pending change (which should be what I passed into pendedit). Any thoughts on why the app isn't marking the files as having a pending edit in the workspace?
Make sure you're doing everything in the right order so TFS knows that the file has changed. You have to:
Get the file from the workspace first.
Pend the edit
Make the changes to the file
Check in the workspace.
Example:
GetStatus status = workspace.Get(new GetRequest(migrationPath, RecursionType.None,
VersionSpec.Latest),GetOptions.Overwrite);
workspace.PendEdit(migrationPath);
checkInAuthor = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
It turned out that even though I had added the files and checked in the files, it seemed that the workspace didn't recognize that the files were there, and as a result I had to do a Get() prior to the PendEdit()