|
There is an app called 'wholockme' that will tell you what process is locking a file, so it must be possible. The only way I know to check is to do your file access in a try/catch, but if you could work out how to tell who has the lock, that would obvioulsy tell you.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
FYI:
if you want write or delete access (anything other than read access) to a file
that just got created (by yourself or someone else, does not matter),
chances are you will find the file is being accessed by some other process,
and your access is not granted.
The other process very likely is some server code that is there to assist you
somehow. Candidates are:
- anti-virus software (Norton, McAfee, whatever)
- indexing software (Google Desktop, MS Office, whatever)
The common thing is these packages are looking all the time for new files, so
they can inspect them.
Microsoft is aware of the consequences; Windows Explorer will try rename and
delete attempts up to five times (with one-second interval), and only reports
failure if the action continues to fail for that time.
The solution:
1. either use a different file name
2. or remove all background reader candidates (bad idea)
3. or implement the retry loop as Explorer has it (use a Windows.Forms.Timer
for this)
BTW: if all you need is Read, make sure to allow others to read as well, i.e.
use File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read)
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Thanks to both of you for your replies. I had the logic in a try catch, but it was a fairly wide open section of code. I narrowed down the code to several try catch sections and did exactly what Luc suggested as solution #3. I setup logic to retry the delete up to 6 times with a delay of 20 seconds between, and it worked.
The application I was having trouble with, has been in production working flawlessly for two years. It takes report spoolfiles off of our miniframe and translates them into PDF for delivery via e-mail or posting on our intranet. The problem came into light when my boss tried to put a 4000 page financial report which was 35MB in size through the application. It worked and sent a 7MB PDF to him via e-mail, but errored out when it tried to delete the original data / report file.
Thanks for your help! It's working flawlessly again.
Lost in the vast sea of .NET
|
|
|
|
|
Hello
Im using a background image on my form, and some pictureboxes that are used as buttons.
I load some other forms from the main form with the same setup(background picture+pictureboxes)
I takes quite a while to load this images.
Is there a way i can preload the images, or speed up the image loading?
Thank you
|
|
|
|
|
Hi,
if the images are much larger than what you need (hence the PictureBoxes will scale them
down), you could create smaller or even correctly sized images once and store them either
in separate files, or as resources in your exe/dll. This would, for each form, save both
the time to load the larger images, and the time to scale them down.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Already doing that
More ideas?
|
|
|
|
|
OK, time to get more specific. I'm looking for something (slightly) unusual:
What is your hardware? modern CPU, RAM size, disk speed?
what about your form(s): size, number of PictureBoxes, number of other Controls?
what is the size of the image files on disk? and in pixels? which format?
SiXke wrote: I takes quite a while to load this images
like how long? 100msec, 1sec, 10sec?
anything special about your code? extra events, extra logging?
network involved? database involved?
as a reference, you could maximize, then minimize, then measure the restore time;
and possibly show the Resize and/or Paint handlers involved.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Luc Pattyn wrote: What is your hardware? modern CPU, RAM size, disk speed?
4000+ / 2GB RAM / Raptor 10.000rpm
Luc Pattyn wrote: what about your form(s): size, number of PictureBoxes, number of other Controls?
Form size: 1920*1080 - 4 Picture boxes - No other controls
Luc Pattyn wrote: what is the size of the image files on disk? and in pixels? which format?
Background image: 1920*1080(97Kb) Pictureboxes: 300*300 (x4)(50-60Kb) all JPEG
Luc Pattyn wrote: like how long? 100msec, 1sec, 10sec?
Say like 1 sec, for example, when the form opens, i see the background, and a sec later the pictureboxes.
Luc Pattyn wrote: anything special about your code? extra events, extra logging?
nothing, simple FrmSub.show on the pictureboxes
Luc Pattyn wrote: network involved? database involved?
no network, access database used in the program, but has nothing to do with the pictures, and is not loaded during form load.
Luc Pattyn wrote: and possibly show the Resize and/or Paint handlers involved.
where can i find this?
Thnak you for your help man.
Do you think it would help to change from JPEG to GIF? (Pictures have max 10 different colors)
|
|
|
|
|
Hi,
it all sounds very reasonable.
and 1 sec is not too bad either.
SiXke wrote: where can i find this?
If you don't know, you don't have them, and they can't be a problem...
Here are a couple of things you could try:
1. a simpler image format for the pictureboxes, such as GIF.
2. embedding the images in the app itself, as resources.
3. set Form.DoubleBuffered true; that will not really solve much but it may change the look and
feel in the way you prefer (I expect it to show the form a bit later but with less activity!).
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Luc Pattyn wrote: 3. set Form.DoubleBuffered true; that will not really solve much but it may change the look and
feel in the way you prefer (I expect it to show the form a bit later but with less activity!).
Just what i needed.
Thx man
|
|
|
|
|
Hi again
The forms with only pictureboxes work like i want, but i have some forms with lots of labels and textboxes, and they still load slow.
Is there a way to preload a form?
I dont mind waiting on a form to load, i mind that the form is loaded in pieces.
Thank you again
|
|
|
|
|
hi... someone can help me it this. i once have made a application that users login using my forum login but now i installed phpbb 3 and the password hash is not md5 anymore!!! someone can tell me how can i make the password hash for this ? i think its utf8_bin but not sure. im confused. the passwords in the database have this format -
Ex:
$H$9DL4NAPoOsmVdZpIrOJcH3KfvVoV3h1
this hash translated is - 11293045
how can i make a user autenticate is this...
thanks
this is a sample php class that does the job but dont know how to make this in vb.net
class PasswordHash {
var $itoa64;
var $iteration_count_log2;
var $portable_hashes;
var $random_state;
function PasswordHash($iteration_count_log2, $portable_hashes)
{
$this->itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
if ($iteration_count_log2 < 4 || $iteration_count_log2 > 31)
$iteration_count_log2 = 8;
$this->iteration_count_log2 = $iteration_count_log2;
$this->portable_hashes = $portable_hashes;
$this->random_state = microtime() . getmypid();
}
function get_random_bytes($count)
{
$output = '';
if (($fh = @fopen('/dev/urandom', 'rb'))) {
$output = fread($fh, $count);
fclose($fh);
}
if (strlen($output) < $count) {
$output = '';
for ($i = 0; $i < $count; $i += 16) {
$this->random_state =
md5(microtime() . $this->random_state);
$output .=
pack('H*', md5($this->random_state));
}
$output = substr($output, 0, $count);
}
return $output;
}
function encode64($input, $count)
{
$output = '';
$i = 0;
do {
$value = ord($input[$i++]);
$output .= $this->itoa64[$value & 0x3f];
if ($i < $count)
$value |= ord($input[$i]) << 8;
$output .= $this->itoa64[($value >> 6) & 0x3f];
if ($i++ >= $count)
break;
if ($i < $count)
$value |= ord($input[$i]) << 16;
$output .= $this->itoa64[($value >> 12) & 0x3f];
if ($i++ >= $count)
break;
$output .= $this->itoa64[($value >> 18) & 0x3f];
} while ($i < $count);
return $output;
}
function gensalt_private($input)
{
$output = '$P$';
$output .= $this->itoa64[min($this->iteration_count_log2 +
((PHP_VERSION >= '5') ? 5 : 3), 30)];
$output .= $this->encode64($input, 6);
return $output;
}
function crypt_private($password, $setting)
{
$output = '*0';
if (substr($setting, 0, 2) == $output)
$output = '*1';
if (substr($setting, 0, 3) != '$P$')
return $output;
$count_log2 = strpos($this->itoa64, $setting[3]);
if ($count_log2 < 7 || $count_log2 > 30)
return $output;
$count = 1 << $count_log2;
$salt = substr($setting, 4, 8);
if (strlen($salt) != 8)
return $output;
# We're kind of forced to use MD5 here since it's the only
# cryptographic primitive available in all versions of PHP
# currently in use. To implement our own low-level crypto
# in PHP would result in much worse performance and
# consequently in lower iteration counts and hashes that are
# quicker to crack (by non-PHP code).
if (PHP_VERSION >= '5') {
$hash = md5($salt . $password, TRUE);
do {
$hash = md5($hash . $password, TRUE);
} while (--$count);
} else {
$hash = pack('H*', md5($salt . $password));
do {
$hash = pack('H*', md5($hash . $password));
} while (--$count);
}
$output = substr($setting, 0, 12);
$output .= $this->encode64($hash, 16);
return $output;
}
function gensalt_extended($input)
{
$count_log2 = min($this->iteration_count_log2 + 8, 24);
# This should be odd to not reveal weak DES keys, and the
# maximum valid value is (2**24 - 1) which is odd anyway.
$count = (1 << $count_log2) - 1;
$output = '_';
$output .= $this->itoa64[$count & 0x3f];
$output .= $this->itoa64[($count >> 6) & 0x3f];
$output .= $this->itoa64[($count >> 12) & 0x3f];
$output .= $this->itoa64[($count >> 18) & 0x3f];
$output .= $this->encode64($input, 3);
return $output;
}
function gensalt_blowfish($input)
{
# This one needs to use a different order of characters and a
# different encoding scheme from the one in encode64() above.
# We care because the last character in our encoded string will
# only represent 2 bits. While two known implementations of
# bcrypt will happily accept and correct a salt string which
# has the 4 unused bits set to non-zero, we do not want to take
# chances and we also do not want to waste an additional byte
# of entropy.
$itoa64 = './ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
$output = '$2a$';
$output .= chr(ord('0') + $this->iteration_count_log2 / 10);
$output .= chr(ord('0') + $this->iteration_count_log2 % 10);
$output .= '$';
$i = 0;
do {
$c1 = ord($input[$i++]);
$output .= $itoa64[$c1 >> 2];
$c1 = ($c1 & 0x03) << 4;
if ($i >= 16) {
$output .= $itoa64[$c1];
break;
}
$c2 = ord($input[$i++]);
$c1 |= $c2 >> 4;
$output .= $itoa64[$c1];
$c1 = ($c2 & 0x0f) << 2;
$c2 = ord($input[$i++]);
$c1 |= $c2 >> 6;
$output .= $itoa64[$c1];
$output .= $itoa64[$c2 & 0x3f];
} while (1);
return $output;
}
function HashPassword($password)
{
$random = '';
if (CRYPT_BLOWFISH == 1 && !$this->portable_hashes) {
$random = $this->get_random_bytes(16);
$hash =
crypt($password, $this->gensalt_blowfish($random));
if (strlen($hash) == 60)
return $hash;
}
if (CRYPT_EXT_DES == 1 && !$this->portable_hashes) {
if (strlen($random) < 3)
$random = $this->get_random_bytes(3);
$hash =
crypt($password, $this->gensalt_extended($random));
if (strlen($hash) == 20)
return $hash;
}
if (strlen($random) < 6)
$random = $this->get_random_bytes(6);
$hash =
$this->crypt_private($password,
$this->gensalt_private($random));
if (strlen($hash) == 34)
return $hash;
# Returning '*' on error is safe here, but would _not_ be safe
# in a crypt(3)-like function used _both_ for generating new
# hashes and for validating passwords against existing hashes.
return '*';
}
function CheckPassword($password, $stored_hash)
{
$hash = $this->crypt_private($password, $stored_hash);
if ($hash[0] == '*')
$hash = crypt($password, $stored_hash);
return $hash == $stored_hash;
}
}
?>
-- modified at 12:50 Thursday 15th November, 2007
|
|
|
|
|
This forum is for asking specific VB(.NET) questions. No one is going to do your work and convert your PHP code for you. You should research the classes in the System.Security.Cryptography namespace.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
i dont need nobody to make my work, i just need someone tell where to start!!!!!
where to find some references related to this!! just that!
|
|
|
|
|
Search CodeProject, search the web. Then come back when you've got a more specific question to ask.
BTW, it's unlikely that anyone is going to understand your PHP code if you post it in a Visual Basic forum!
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Take a look at this thread on PHPBB support forum (if you haven't seen it already):
http://www.phpbb.com/community/viewtopic.php?f=71&t=585387&st=0&sk=t&sd=a[^]
I am actually working on something similar to what you are looking for, trying to translate the Hashing Class to its VB.NET equivalent. Contact me at webmaster@digioz.com and maybe we can work on it together.
Pete Soheil
DigiOz Multimedia
http://www.digioz.com
|
|
|
|
|
Hi! I am new here so please forgive me of being a noob. I have a question though a friend and I are trying to make a new and better toolbar instead of the mac and xp one. We would like to know is it possible to keep windows made with vb.net in an absolute order
and is it possible to have three windows made into one without moving or closing the space in between? Sorry for not explaining well it's hard to describe. Anyway if you guys could help that would be great!
|
|
|
|
|
|
hi all
i want to retreave text that has COlumns from sn html page.in that html page there is a table like this,
UnitNumber|Ownwer |Title Deed|Registration_date| Purchase_Price |Details
========================================================================
1 James ST545454 20071115 $154000000 Yes
Bond .
So thats how my html looks like, so i want to retreave this data and put in in a SQL table. i have already created the table. i want to know how to do it in vb.net
Thanks
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
You'll have to parse the HTML to get the values for each row. You could do this with regular expressions or with some string manipulation.
Why are you doing this though? Unless you are writing a screen-scraping application, it doesn't seem like a good idea.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
hi pmarfleet
Thanks for your reply
There is a website that we look at to retrieve information, but now its time consuming to do the copy and paste, we were thinking of writting a Program that will extract that info and put it in a SQl table for us.
How can we achieve this?
Thanks
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
I've suggested ways that you could do this. I'm not going to do your work for you. Look at how the HTML markup is constructed and then research and write a regular expression to extract the information you want.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Thanks
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Greetings
I have written an insert routine that has the text boxes and a grid with populated with the target "insert" table on the same form.
I am using data bindings:
txtLastName.DataBindings.Add("Text",dsMusicStore, "Customers.LastName")<br />
txtFirstName.DataBindings.Add("Text", dsMusicStore, "Customers.firstName")
Code for the insert
Dim comBuilder As New OleDb.OleDbCommandBuilder(daCustomers)<br />
Dim dsNewRow As DataRow<br />
dsNewRow = dsMusicStore.Tables("customers").NewRow<br />
dsNewRow.Item("FirstName") = txtFirstName.Text<br />
dsNewRow.Item("LastName") = txtLastName.Text<br />
dsMusicStore.Tables("customers").Rows.Add(dsNewRow)<br />
daCustomers.Update(dsMusicStore, "customers")<br />
grdCustomers.Update()<br />
Me.Refresh()
Problems:
1. When I start entering data into the textbox, the data overwrites data in the top line of the grid
2. When I save, the data in the first line is still overwritten and the new record falls to the bottom of the grid. If I close the form and reopen it, the data first line data has been restored and the new data takes its place on the grid in the proper position for the given index
How can I:
1. stop the first line on the grid from being overwrttien (short of unbinding the data
2. Update the data grid upon save so the record displays where it should (not at the bottom)
Just Do It
|
|
|
|
|
Hi all,
how to get the Full path of a Shared Network Folder.
i have a folder named DBBackup in Server Computer.
from Client computer the above path is \\Server\DBBackup.
Actually 'DBBackup' folder in D Drive of Server Computer.
i need to get this Path Like '\\Server\D\DBBackup' Or 'D:\DBBackup'.
can you give any valuable information about this.
By
George Garvasis
|
|
|
|
|