|
Thanks for replying to this. Didn't have the opportunity earlier. This was exactly the thing what I was trying to explain.
|
|
|
|
|
I m trying to open a zip file selected by user and extracting it....
It runs fine for the first time but when i again clicks on the open file button and selects a zip file. It throws an exception:
The process cannot access the file "file.png" because it is being used by another process
Note: file.png being one of the files extracted from the .zip file.
I think the FileStream object is not releasing the file after opening it. I tried using f.Destroy() and f.close() but they didnt work. Also the code runs for the first time successfully and it creates an error when another .zip file is opened (using the openfiledialog box) after opening the first file successfully.
String filename = openFileDialog1.FileName;
ZipInputStream zis = null;
FileStream f = new FileStream(filename, FileMode.Open);
zis = new ZipInputStream(f );
ZipEntry ze=null;
while ((ze = zis.GetNextEntry()) != null)
{
FileStream fs = null;
fs =System.IO.File.Create("d:\\puzzlesolver\\pieces\\"+ze.Name);
int size = 2048;
byte[] data = new byte[2048];
while (true)
{
size = zis.Read(data, 0, data.Length);
if (size > 0)
{
fs.Write(data, 0, size);
}
else
{
break;
}
}
fs.Close();
}
f.Close();
f.Dispose();
zis.Close();
zis.Dispose();
|
|
|
|
|
Hi,
this is the most likely explanation:
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)
If you are convinced something else is going on, add try-catch (you should have done that straight away, every time and as soon as you do some I/O), display the entire exception text and the file name, note down the line numbers, tell your IDE to show line numbers, and publish all the details here.
locate the offending line.
|
|
|
|
|
Thank you so much... Your help made it work... i used
FileStream fs;
fs =System.IO.File.Create("d:\\puzzlesolver\\pieces\\"+ze.Name,2048,FileOptions.Asynchronous);
and write the stream on to this file....
|
|
|
|
|
Hello,
Im trying really hard to understand pointers, the good thing is that i understood the basics of pointers, the problem is that there is this question that confused me alot!
Here is the question:
Write and test a function that uses pointers to search for the address of an integer in a given array. If the integer is found, the function returns its address within the array; otherwise it returns NULL.
function to be used: int* search(int* p[], int n)
I tried to solve it but it keeps getting me confused more and more.
Am using Microsoft Visual Basic C++ (.NET).
Am really grateful for any kind of help possible.
Thank You.
|
|
|
|
|
Sorry, we don't do homework for you here.
Boo10 wrote: Am using Microsoft Visual Basic C++ (.NET)
I think this is your problem. What the hell is "visual basic c++ .net"? I think you may be slightly confused about what language you're using. (Check with your lecturer that you are using the same language as them. You will struggle to do this in the wrong language. As far as I'm aware, visual basic doesn't support pointers)
Break it down into steps. If you understand pointer basics like you say, each step should be fairly straight forward to write.
You need to write a function that take a pointer to an array of integers and an integer to search for. You need to loop through the array and check if any of the values it contains matches the integer you are searching for. When you find a match, you need to get a pointer to that value and return the pointer. If you don't find a match and get to the end of the array, you just return a null pointer.
Simon
|
|
|
|
|
Simon Stevens wrote: What the hell is "visual basic c++ .net"?
Nice catch. I wonder what the hell that was
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Boo10 wrote: Am using Microsoft Visual Basic C++ (.NET)
No such thing as Visual Basic C++. There is either Visual Basic or C++, make up your mind.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Attend an upcoming MSDN Developer Conference [^]and you will receive a Windows 7 Beta 1 DVD either at the event or mailed to you (depending on Windows 7 Beta release date).
Register today [^]and you’ll get the best of the PDC in your own backyard and hear all of the exciting announcements around the Azure Services Platform and Windows 7. The day-long conference is held in Houston TX, Orlando FL, Atlanta GA, Chicago IL, Minneapolis MN, Washington DC, New York NY, Boston MA, Detroit MI, Dallas TX, and San Francisco CA between December 9 and February 19.
- Experience Windows Azure. Create applications that seamlessly bridge the gaps between PC, Web, and phone
- Be among the first to see Windows 7. See the latest advances in Multi-Touch Application Development.
- Take your .NET skills to the next level. See sessions on WPF 4.0, Silverlight 2, The Future of C# and VB, ASP.NET 4.0, Live Mesh and more
Check out the sessions here[^]. Cost is $99.
|
|
|
|
|
Hi,
I wrote an application that able to connect another bluetooth device in .Net Framework 2.0 using bluetooth API, now I want to do this with .Net Compact Framework on my mobile device. That's the problem, When I'm Calling Bluetooth API like WSAStartup or using SizeOf method of Marshal class, it gives me NotSupportedException exception.
Please tell me how can i solve this problem.
Thank you.
DMASTER
|
|
|
|
|
You're going to have to rewrite the code to do whatever it is you want a different way, since, well, what you're doing now is NotSupported on .NET CF.
BTW: You might want to post future queries to this problem in the Mobile Development Forum.
|
|
|
|
|
Thanks for your reply dear Dave.
But I hadn't rewrite my previous code in .net compact framework, I know all methods and parameters that should be set on .net compact framework. Ok, Lets suppose that you are right, so what about SizeOf Method . If you refer to msdn, you can see that, it's marked as supported on .net CF.
Thank you.
|
|
|
|
|
You never showed the code and line where the exception occured, so it's impossible to say anything else.
|
|
|
|
|
I am creating n pictureboxes and then setting a different image on each one of them in a loop. The user clicks on open n opens a .zip file (containing images only). I am unzipping the .zip contents in a folder and am able to extract the images from there.For the first time the pictureboxes rightly shows the images. But when again user click on the open button and select a .zip file to be opened. The new images doesnt appear completely.
Problem could be: previous images are not getting removed so are not allowing the new images to appear.
Language: c#
code:
pb = new PictureBox[r*c];
Point point = new Point(100, 100);
for (i = 0; i < r * c; i++)
{
pb[i] = new PictureBox();
{
pb[i].Dispose();
}
pb[i].Image = null;
}
int w = 800 / r;
int k = 0;
int h = 700 / c;
int a = w, b = h;
for (i1 = 0; i1 < r; i1++)
{
b = 15;
for (i2 = 0; i2 < c; i2++)
{
pb[k] = new PictureBox();
pb[k].Image = null;
pb[k].Size = new Size(w, h);
this.Controls.Add(pb[k]);
if (i1 == 0 )
{
pb[k].Location = new Point(10, b);
}
else
{
pb[k].Location = new Point(a, b);
}
b = b + h;
Bitmap img=new Bitmap("d:\\puzzlesolver\\pieces\\piece"+i2.ToString()+i1.ToString()+".png");
Bitmap img1 = new Bitmap(img);
pb[k].Image = img1;
pb[k].SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
pb[k++].Update();
this.Update();
}
a = a + w;
}
this.Update();
I have tried a lot of things please tell me how to remove the existing picture boxes which are dynamically allocated and then add them again. I hope m clear!!
|
|
|
|
|
heyy, please reply to this question guys................
|
|
|
|
|
You should not push people to reply to your question. Either the person who knows what is the problem hasn't seen it yet, or nobody knows. Exercise a little patience.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
for (i = 0; i < r * c; i++)
{
pb[i] = new PictureBox();
{
pb[i].Dispose();
}
pb[i].Image = null;
}
This is almost certainly not doing what you expect. You are creating new PictureBoxes and immediately Disposing them.
this.Controls.Add(pb[k]);
Every control added to a Form stay on the form until you call this.Controls.Remove with the same control. Disposing the control before removing it from the form may cause an exception, so make sure you do it in the right order.
|
|
|
|
|
Thnk you for replying..... i was successfully able to handle the problem that i was facing
|
|
|
|
|
Hi to all,
I have a third parity DLL that I need to use.
I have some examples written in VB6 and C++
I tried to convert a function declaration from VB6 to VB.NET
My conversion doesn't works correctly.
Problem specifications
1. In the DLL there are 2 function called "EupicdsmGetFlashInfo" and "EupicdsmGetFlashInfoW"
2. The c++ declarations are:
EUPICDSM_LINK int __stdcall EupicdsmGetFlashInfo(
const int index,
int& numDrives,
char* drives,
int& drives_len,
char* serial,
int& serial_len);
Vendor specifications:
drives [out]
Pointer to char that receives the list of drive letters associated to the device. The drive letters have SCSI
format ( \\.\H: ) and they are separated by the terminating null character (ASCII code 0). A double terminating
null character is the end of list. If this parameter is NULL, function returns EUPICDSM_ERROR_PARAM_LEN
and iDriversLen receives the minimum size for containing the entire list.
EUPICDSM_LINK int __stdcall EupicdsmGetFlashInfoW(
const int index,
int& numDrives,
BSTR* pDrives,
BSTR* pSerial);
Vendor specifications:
pDrives [out]
Pointer to wide character string that receives the list of drive letters associated to the device. The drive
letters have SCSI format ( \\.\H: ) and they are separated by the terminating null character (ASCII code 0). A
double terminating null character is the end of list.
3. The VB6 declarations are:
EupicdsmGetFlashInfo - NOT DECLARED in the example !
Declare Function EupicdsmGetFlashInfoW Lib "eupicdsm.dll" (
ByVal iIndex As Long,
ByRef iNumDrives As Long,
ByRef pDrives As String,
ByRef pSN As String) As Long
4. My VB.NET conversion:
Declare Function EupicdsmGetFlashInfo Lib "eupicdsm.dll" (
ByRef index As Long,
ByRef numDrives As Long,
ByRef drives() As Byte,
ByRef drives_len As Long,
ByRef serial() As Byte,
ByRef serial_len As Long) As PD_RETURNVALUES
Declare Function EupicdsmGetFlashInfoW Lib "eupicdsm.dll" (
ByRef iIndex As Long,
ByRef iNumDrives As Long,
ByRef pDrives As String,
ByRef pSN As String) As PD_RETURNVALUES
Problem:
The result of function EupicdsmGetFlashInfoW (as declared at point 4.) is wrong:
only the name of the first driver (even if there are more ex. 2 or 3) is returned in the pDrives String.
I suppose the trouble may be in the use of null character (ASCII code 0) as separator.
So I tried to use the "EupicdsmGetFlashInfo" but it gives an error.
Is there someone who can halp me?
how can I change the declaration? is it better to use "EupicdsmGetFlashInfo"?
thanks in advance
Bye
Boris
|
|
|
|
|
Am Developing an windows application in .NET 2.0 Framework.
The scenario is like,
In User interface,
We have textbox's for username & another for password.
The user will enter username & then he press enter key, after pressing enter key the cursor must come to password textbox, can any please solve the problem.
Am unable 2 study abt the ENTER key, generally V can have through by pressing tab key,
but client request is only throught enter key......
Thank you in advance...
Hope u people will b solving it...
|
|
|
|
|
You need to handle the keydown or keypressed event on the text box. In this event handler, you can check what key was pressed. If the enter key was pressed, you can set focus to the next control by calling .Focus() on the control.
Simon
|
|
|
|
|
look for the key pressed is e.keycode==13 .... for enter key
then txtpassword.focus()
thanks
Tony
|
|
|
|
|
|
Well, you don't have much of a choice but to process all deletes first, then go through and add the rows. The TableAdapter goes through the rows, one-by-one and processes them according to their state. If, by chance, you've added a row to a dataset, then you've pretty much duplicated a key because the adapter hasn't gotten to the deleted row yet and executed the SQL for it. Normally, people don't reuse key values.
|
|
|
|
|
can we use WCF in an application using Frameworks .NET 2.0 without installing 3.0 version.
Imean is there any extensions to add to frameworks 2.0???
thank you for you answer
|
|
|
|
|