From within my project, I am opening an file elsewhere on the network and
changing contents within.
When I go to close/save, however, I can't because it's read-only (as it's
checked in).
Can I just flip read-only off, make my changes and save it, and then flip
read only back on (programmatical ly)? How can I do this, please?
Thanks. 1 4283
rcook349 kirjoitti:
From within my project, I am opening an file elsewhere on the network
and changing contents within.
When I go to close/save, however, I can't because it's read-only (as
it's checked in).
Can I just flip read-only off, make my changes and save it, and then
flip read only back on (programmatical ly)? How can I do this, please?
Thanks.
using System.IO;
if (File.Exists(fi leName))
{
FileAttributes attrs = File.GetAttribu tes(fileName);
File.SetAttribu tes(fileName, attrs & ~FileAttributes .ReadOnly);
MakeTheChanges( fileName);
attrs = File.GetAttribu tes(fileName);
File.SetAttribu tes(fileName, attrs | FileAttributes. ReadOnly);
}
There is two calls to GetAttributes, since most likely your
MakeTheChanges sets at least the archive bit.
--
Arto Viitanen This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jak Sparrow |
last post by:
What are some good ways to programmatically check for software already
installed on a computer?
For example, to check a version of Internet Explorer, a program can check
the registry for the following value:
Version, and see if the version
is 6.0 or not.
However, not all installed software can be checked as easily. For example,
Windows Media Player 9 has the following registry path:
|
by: Alexandra |
last post by:
Hi,
I have a hidden system file that I need to read.
I am logged in as an administrator.
I can not change the file attributes using the windows explorer.
|
by: |
last post by:
I have a "form field highlight" javascript that I've added to some of my
ASP.NET forms using the following syntax:
body.Attributes.Add("onClick", "highlight(event);");
body.Attributes.Add("onKeyUp", "highlight(event);");
Some of my forms have a great many text box controls that I want to
highlight.. I would much rather that ASP.NET do the work of looping through
all text boxes and applying these two attributes.
|
by: Reza Solouki |
last post by:
Hello,
I never had to do anything with office tools programmatically till now(I
guess there is first time for everything), so this might be a very silly and
simple question for some of you.
Any way, the new system that I am programming will need to be feeded daily
with an excel file. So I need to read a given file and write it to the
database - hopefully they all will follow the same structure.
My issue is I haven't found anything...
|
by: forest demon |
last post by:
for example, let's say I do something like,
System.Diagnostics.Process.Start("notepad.exe","sample.txt");
if the user does a SaveAs (in notepad), how can i capture the path that
the user selects?
thanks...
| |
by: Nathan Sokalski |
last post by:
I need to programmatically set the action attribute of the form tag. First
of all, the ASP.NET form control does not have an action property (it shows
the Action attribute in source view, but not as a property in the code).
Because of this, I have been using the following to set it:
Me.form1.Attributes.Add("action", "http://www.mysite.com/file.aspx")
However, because ASP.NET posts back to itself by default, the generated code
still has
|
by: Tim Zych |
last post by:
I would like a way to scan the code in a vb.net project, say by creating a
vb.net utility to cycle through each line of code related to a particular
project and perform some analysis on it.
How do I program into the IDE? Did I ask that right? I need a way to
programmatically cycle through each line of code, for any code that's
related to a project.
thanks for any pointers.
|
by: Brian Roisentul |
last post by:
Hi everyone,
I've been investigating for a while about this, but with no luck yet.
Does anybody know a way to do it?
Many thanks,
Brian
|
by: =?Utf-8?B?UGV0ZXIgSw==?= |
last post by:
I am working with Visual Studio or alternately with Expression Web. I need
to create about 50 aspx pages with about 1200 thumbnali images, typically
arranged in three to four groups per page, having hyperlinks to the
corresponding full size images.
Can anybody point me to locations in MSDN or elsewhere giving the references
to attach, the commands & objects for creating or opening the pages and
possibly available classes?
I have done...
|
by: Andrew Jocelyn |
last post by:
Hi
How do I programmatically change (read/write) the values in this app.config
file at runtime? Specifically I want to change the client endpoint address
but it would be nice to change other values too. I thought this is what
ServiceHost is for but is seems way more complicated to use for what I'm
trying to do.
<system.serviceModel>
<bindings>
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |