473,796 Members | 2,538 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

file deletable?, shortcuts, .mdb file backup

Hi All!!
Could you please help me with three problems:

1.
I would like to have a procedure that returned true if the file is
writtable=delet able.. I tried everything but so far the only way I can
really tell if the file can be delete is to actually try to delete it and
catch an exception.. Trying to open a file with StreamReader in write mode
didn't work as expected.

2:
I know how to create shortcut, using COM API, but I can't seem to find
parameter for setting shortcuts name when put for example on Start Meni.. if
I don't set this, then the name of link is just the name of file, which is a
little bit ugly.

my code is here.. note the line, marked with ###

public static void CreateShortcut( string name, string shortcut_dir, string
app_path, string description)
{
// Get the app path and filename
//string app = app_path;
try
{
// Create a Windows Script Host Shell class
IWshShell_Class shell = new IWshShell_Class Class();

//get application executable from entire path
string app_file = Path.GetFileNam e(app_path);

// Define the shortcut file
IWshShortcut_Cl ass shortcut = shell.CreateSho rtcut(shortcut_ dir + "\\" +
app_file + ".lnk") as
IWshShortcut_Cl ass;

// Set all its properties
//### I thought the following line was what I was looking for.. but when
I tried to set this,
//compiler says it is only readonly field.. so.. my question is: is this
the field and this is the bug, or should I do something else to set the real
name of the shortcut which user sees?
//shortcut.FullNa me = name;
shortcut.Workin gDirectory = Path.GetDirecto ryName(app_path );
shortcut.Target Path = app_path;
shortcut.IconLo cation = app_path + ",0";
if(description != null)
{
shortcut.Descri ption = description;
}

// Save it
shortcut.Save() ;
}
catch(COMExcept ion ex)
{
Console.WriteLi ne(ex.Message);
}
}

3.
I would like to periodically make a backup copy of all .mdb files while the
application is running in the background (it is database server .. c#
remoting, ADO.NET).
The thing is that not all the recent changes are in those .mdb files, when I
copy them.. if I reset the server, then the files are up-to-date.
I see the solution in two possible ways:
somehow get all the data from ADO.NET objects and create new mdb files.
or..somehow forcing ADO, to write all the pending actions before physically
copying .mdb files.
I am currently traveling, so my access to internet, book and other
information is restricted.. I've been fighting with those problems for some
time, but then I came to blind alley. Your help would be greatly
appreciated.
Thank you so much!!!

David Krmpotic

Nov 16 '05 #1
2 2293
For your first question, you can check that if a file is ReadOnly or
not.

System.IO.FileI nfo fi = new FileInfo("yourF ilePathgoesHere ");
if((fi.Attribut e & System.FileAttr ibutes.ReadOnly ) ==
System.FileAttr ibutes.ReadOnly ) //If File is readonly
//Don't delete.

Maqsood Ahmed
Kolachi Advanced Technologies
http://www.kolachi.net

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #2
Thank you for response.. but I am afraid that this doesn't work for me.. I
think I didn't express myself clearly. I needed a procedure that would tell
me if the file is in use and thus not writable/deletable.

I tried your recommendation, but file's ReadOnly flag is not set when file
is in use.

I just found other easy solution:

public static bool IsFileInUse(str ing file)
{
try
{
FileStream fs = File.OpenWrite( file);
fs.Close();
return false;
}
catch
{
return true;
}
}

I was close before, but I used OpenRead instead of OpenWrite. The problem
was that you can open the file for reading although it's already open for
reading somewhere else (and thus not deletable). But you can only open the
file for writing it absolutely nothing is currently accessing it.
Thank you !!

PS: do you have any ideas about my second two questions.
"Maqsood Ahmed" <ma***********@ gawab.com> wrote in message
news:eZ******** ******@TK2MSFTN GP15.phx.gbl...
For your first question, you can check that if a file is ReadOnly or
not.

System.IO.FileI nfo fi = new FileInfo("yourF ilePathgoesHere ");
if((fi.Attribut e & System.FileAttr ibutes.ReadOnly ) ==
System.FileAttr ibutes.ReadOnly ) //If File is readonly
//Don't delete.

Maqsood Ahmed
Kolachi Advanced Technologies
http://www.kolachi.net

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
3308
by: Bing Du | last post by:
Greetings, Our former SQL Server 2000 DBA backed up everything in a single disk file. By everything I mean, full backup, differential backup and transaction logs. See below for details of how the backup is currently set up. When I did 'view contents' of DBBackup, I saw it contained the mixture of log, full and diff backups of verious dates. She has quit. Other coworkers said (in a not-sure tone) she was able to restore the databases...
4
12727
by: news | last post by:
Our production database in an exported textfil runs about 60 MB. Compressed that's about 9 MB. I'm trying to import the export into another machine running FC3 and mySQL 11.18, and it appears as though the file may be too big! When I try to do it via command line: mysql -u root --host=localhost printing < ./printing.txt It eventually errors out with a "syntax error on line X" and only about
3
5637
by: Stanislaw Findeisen | last post by:
Does anyone know how to create file shortcuts in Windows? The only way I know is like: --------------------------------------------------------------- import win32com.client wScriptShellObject = win32com.client.Dispatch("WScript.Shell") shortcutName = unicode("shortcut.lnk", "utf8")
6
5199
by: Charles Morrall | last post by:
I have no experience with DB2 as such, but I've been tasked with configuring backup of a server running DB2 v8 on Windows Server 2003. I do have some experience with backups in general though. The backup software I'll be using is Backup Exec 10, but Backup Exec doesn't have a specific agent for DB2, as it does for SQL and Oracle. The supplier of Backup Exec claims I can use the Open File option of Backup Exec to backup DB2. I find this a...
23
2658
by: Francesco Zavatarelli | last post by:
I downloaded a free c-compiler and I'm trying to access a file in a windows directory c:\program files\... but I get an error when I run the code. Probably my declaration char* NAME is wrong. Anybody can give a suggestion? Thanks very much. Fzavat char* NAME_SMS = "c:\\Program Files\\Palm\\Tungst\\Backup\\SmsDB.PDB"; file_sms = fopen(NAME_SMS, "r");
0
1192
by: GeorgeF | last post by:
How can I conditionally deploy shortcuts to my application? I have created a custom installer dialog box to give my users the option of creating desktop/start menu shortcuts, but the shortcuts do not have a Condition property that allows conditional deployment. I have tried using the Condition property of the folder where the shortcuts are being installed to, but the shortcuts get installed whether the options are selected or not. I have...
4
3662
by: Robert Iver | last post by:
Hello everyone, I am trying to create an application that utilizes a SQL Mobile database. I have included that database in my main project, and it compiles and debugs just fine. I then created a custom installer project packaged as a class library and made an installer project to wrap the whole thing up into an MSI package. Basically the idea behind doing all this is so the handheld app can be pushed out through group policy.
1
1097
by: googleboy | last post by:
I need to create about 2000 shortcuts to a batch file. The shortcuts need to have: Name: %parameter%.lnk Target: n:\Path\To\batchfile.bat %parameter% Start In: n:\Path\To\ Where the parameter is filled in by reading in a file with all the
3
12861
by: maheshkadam | last post by:
Hi friends I am new to perl so please guide me. I have one application which created backup log file every day.But it appends that file so you can see logs for different day in one file only. My requirement is to copy backup log for the specific day (yesterday) and write in other file. That file will be mailed to admin for ready reference. So here is some text from that log file
0
9684
marktang
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...
0
10459
Oralloy
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...
0
10236
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10017
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7552
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6793
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();...
0
5577
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3734
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2928
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.