|
I am writing a C# program to ruturn the permissions of a reg key passed in the program. I have the main registry part working except when the registry path has a space.
RegistryKey
regKey = Registry.LocalMachine
regkey = regKey.OpenSubKey("Software");
regkey = regKey.OpenSubKey("Adobe");
regKey = regKey.OpenSubKey("Adobe Reader");
RegistrySecurity = regKey.GetAccessControl();
the main question is how do I handle spaces so I can read any key I am looking for?
Thanks
Rob
|
|
|
|
|
I just tried this code with "Adobe Gamma" (I don't have the reader installed) and it worked fine for me.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thanks
I did not have the right key name
|
|
|
|
|
I am getting a warning message while sending mails,meeting rquests programatically. How to suppress these warnings?
can you plz help me?
|
|
|
|
|
|
I've killing myself for about a week now on this one thing. Any help would be appreciated. I'm trying to use WebClient.DownloadFileAsync so my GUI stays responsive while a file downloads. Everything works right as far as I can tell. For the split second before the crash, my GUI is still responsive. Here's how it works and where the problem comes in.
I call getfileasync to download "file.ext" from "http://whatever.com". It starts download and when AsyncCompletedEventHandler is triggered, my handler is called that loads the file that was downloaded and does stuff with it. The problem comes in when AsyncCompletedEventHandler is called. It seems like it's calling BEFORE the file is actually downloaded. When I step through in debug bug mode, I have no problems, because the file has time to fully download before I call on it again. In a straight run, I can actually watch as the error is thrown before I see the file show up in Explorer.
Here's some stripped, relevant code.
string fileName;
public void checkUpdates()
{
foreach (Uri uri in uriList)
{
fileName = uri.AbsolutePath.Remove(0, 1);
if (!File.Exists(fileName))
{
doUpdates(true, uri);
wasUpdated = true;
continue;
}
}
}
public void doUpdates(bool checkUpdates, Uri uri)
{
WebClient client = new WebClient();
client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_updateFinished);
if (checkUpdates)
client.DownloadFileAsync(uri, fileName);
}
private void client_updateFinished(object sender, AsyncCompletedEventArgs e)
{
if (File.Exists(fileName))
{
xmlDoc.Load(fileName);
}
}
I noticed that I don't have this problem when I download one file at a time. Or, if I switch the download order so the bigger of the 2 files downloads first, I don't get an error, but the second file isn't processed. After the files download, they're opened by the program and read through(xml) and every node is put into a combo box. The second file doesn't make it to that process function.
The error it throws is:
System.IO.IOException: The process cannot access the file 'file.xml' because it is being used by another process.
I assume because i'm still saving the file as I try and load it again. If I call Thread.Sleep(xxx) or Application.DoEvents it works right, but then i'm blocking again and I may as well go with synchronous sockets.
|
|
|
|
|
The first thing that pops to my mind, is run the downloader in a seperate thread/BackgroundWorker .
|
|
|
|
|
I remember I did this a while ago and never had any problems. I've just gone and checked and it turns out I used a delegate and BeginEnvoke() , although I've never tried to access the file imediatly after I got the callback. Maybe you could add a Thread.Sleep(1000); to make sure everything is finished - although it's not ideal.
Perhaps if you use a delegate like I did you won't have a problem, since this calls DownloadFile rather than the built in DownloadFileAsync , it's got to be worth a try at least.
private delegate void DownloadFile(string Address, string Path);
.
private void download(string Address, string Path)
{
System.Net.WebClient client = new WebClient();
client.DownloadFile(Address, Path);
}
.
private void internetDownload()
{
string address = ReadString();
string path = ReadString();
DownloadFile dload = new DownloadFile(download);
dload.BeginInvoke(address, path, new AsyncCallback(downloadCallback), dload);
}
.
private void downloadCallback(IAsyncResult result)
{
DownloadFile dload = result.AsyncState as DownloadFile;
dload.EndInvoke(result);
}
My current favourite word is: I'm starting to run out of fav. words!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
Hello,
I've got very odd problem.
I use windows application to store files in data base (MySql) and then to extract this files from data base and save it on hdd. But when i save them back to hdd tihs files are 1Kb less from original file. When i insert pictures this 1kb obviously is not imported and the pictures is shown. But other files when try to be opened is corrupted or if they open some error message is shown.
So the code that i use to save file in DB is:
MySqlConnection con = new MySqlConnection("SERVER=localhost;" +
"DATABASE=db;" +
"UID=user;" +
"PASSWORD=root;");
MySqlDataAdapter da = new MySqlDataAdapter("Select * From test", con);
MySqlCommandBuilder MyCB = new MySqlCommandBuilder(da);
DataSet ds = new DataSet("test");
da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
FileStream fs = new FileStream(@"C:\image.rar", FileMode.OpenOrCreate, FileAccess.Read);
byte[] MyData = new byte[fs.Length];
fs.Read(MyData, 0, System.Convert.ToInt32(fs.Length));
fs.Close();
da.Fill(ds, "test");
DataRow myRow;
myRow = ds.Tables["test"].NewRow();
myRow["id"] = "12";
myRow["blobdata"] = MyData;
ds.Tables["test"].Rows.Add(myRow);
da.Update(ds, "test");
con.Close();
The code that extract files from database and save them to hdd is:
MySqlConnection con = new MySqlConnection("SERVER=localhost;" +
"DATABASE=db;" +
"UID=user;" +
"PASSWORD=root;");
MySqlDataAdapter da = new MySqlDataAdapter("Select * From test where id = 12", con);
MySqlCommandBuilder MyCB = new MySqlCommandBuilder(da);
DataSet ds = new DataSet("test");
byte[] MyData;
da.Fill(ds, "test");
DataRow myRow;
myRow = ds.Tables["test"].Rows[0];
MyData = (byte[])myRow["blobdata"];
int ArraySize;
ArraySize = MyData.GetUpperBound(0);
FileStream fs = new FileStream(@"C:\Data\image.rar", FileMode.OpenOrCreate, FileAccess.Write);
fs.Write(MyData, 0, ArraySize);
fs.Close();
Thanks!
King Regards!
countNazgul
modified on Thursday, July 3, 2008 10:42 AM
|
|
|
|
|
countnazgul wrote: byte[] MyData = new byte[0];
What the purpose of that?
countnazgul wrote: int ArraySize = new int();
Whats the purpose of that?
countnazgul wrote: System.Convert.ToInt32(fs.Length-1)
Whats the purpose of that?
Now, remove all that useless crap from your code, so we can at least read and understand it...
|
|
|
|
|
Ok. I remove the piece of code
King Regards!
countNazgul
|
|
|
|
|
Do U Check To See if The Data (file in your case)
was received Successfully and Fully??
there are lots of events and Methods in (MySql/ODBC/OLEDB/SQLserverDataAdapter)
Like the FillError Event
Have Fun
Never forget it
|
|
|
|
|
Yes file was OK.
But i find another solution that extract my files without a problem.
Here is and the code:
MySqlConnection Conn = new MySqlConnection("SERVER=localhost;" +
"DATABASE=db;" +
"UID=user;" +
"PASSWORD=root;");
MySqlCommand Cmd = new MySqlCommand("Select * From test where id = 19", Conn);
Cmd.CommandType = CommandType.Text;
Conn.Open();
MySqlDataReader Reader = Cmd.ExecuteReader(CommandBehavior.CloseConnection);
FileStream FStream = null;
BinaryWriter BWriter = null;
byte[] Binary = null;
const int ChunkSize = 100;
int SizeToWrite = 0;
MemoryStream MStream = null;
while (Reader.Read())
{
FStream = new FileStream(@"c:\Data\Nomenclature123.xls", FileMode.OpenOrCreate, FileAccess.Write);
BWriter = new BinaryWriter(FStream);
Binary = (Reader["blobdata"]) as byte[];
SizeToWrite = ChunkSize;
MStream = new MemoryStream(Binary);
for (int i = 0; i < Binary.GetUpperBound(0) - 1; i = i + ChunkSize)
{
if (i + ChunkSize >= Binary.Length) SizeToWrite = Binary.Length - i;
byte[] Chunk = new byte[SizeToWrite];
MStream.Read(Chunk, 0, SizeToWrite);
BWriter.Write(Chunk);
BWriter.Flush();
}
BWriter.Close();
FStream.Close();
}
FStream.Dispose();
Thank You gays for responses!
King Regards!
countNazgul
|
|
|
|
|
countnazgul wrote: Thank You gays for responses!
I'm straight, thank you.
|
|
|
|
|
I've been at this for a week now and i've only managed to connect to an open sharepoint site (public), but when it comes down to connecting to a password-protected site it becomes a pain and I can neither find nor get any methods to work without exceptions. Any help?
Thanks mates!
-Kevin
Sharp Business Systems
|
|
|
|
|
How to Print a windows form using C# 2008.
The form is just like an Id Card.
How to do that. could you help me.
|
|
|
|
|
|
|
i'm working with DGV and found a little problem that is DGV losses selection when it get clicked before releasing the mouse button, e.g. i have selected 5 rows and if i click on a already selected row then other selected rows get unselected before releasing the mouse button, what i want is, when i click on a already selected row then other selected rows should be keep selected until i release the mouse button like ListView, is there anyway to accomplish this task ?
thanks
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
You are holding down the Control key when selecting?
|
|
|
|
|
no, ok once try it on ListView, i exactly want that, in LV focus do not loss from other selected items until mouse button release
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
At present I have a filesystemwatcher which monitors a folder for the activities of files in that folder.
Now I would like to monitor other folders too.
Can the filesystemwatcher monitor several folders at the same time?
Thanks
|
|
|
|
|
only if all folders are subfolders of the selected folder or drive
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Hi,
I want to implement the Linked list, hash table functionality in .NET without using the collection classes, assuming they are not present.How Can I achieve this?
Regards,
Srinu
|
|
|
|
|
srinivas0099 wrote: How Can I achieve this?
Buy a book on algorithms...
|
|
|
|