|
As I see the file stream remains open .
You may copy the image into MemoryStream, then close FileStream .After this you will be able to delete the file and play with the image as you want.
DevIntelligence.com - My blog for .Net Developers
|
|
|
|
|
Actually prob is that:
i save an image...
but when im update image... i want to delete old image frm my IMAGE folder...
i use..
Image = Image.FromFile(imageFileName)
: and thow the error :
this is used by another procees
help me out .....
thanx
Never Think That You Have Failed Instead Always Think That u hav Better Chance Next Time...
|
|
|
|
|
This code snippet reads image file, show it in PictureBox then delete image file from the disk.
<br />
try<br />
{<br />
MemoryStream ms = null;<br />
FileInfo fi = new FileInfo(textBoxFilePathName.Text);<br />
byte [] buffer = new byte[fi.Length];<br />
<br />
using( FileStream stream = File.Open(fi.FullName, FileMode.Open) )<br />
{<br />
stream.Read( buffer, 0, (int)fi.Length );<br />
ms = new MemoryStream(buffer);<br />
}<br />
<br />
Image img = Image.FromStream(ms);<br />
pictureBox1.Image = img;<br />
<br />
File.Delete( textBoxFilePathName.Text );<br />
<br />
ms.Close();<br />
}<br />
catch (Exception e1)<br />
{<br />
MessageBox.Show( e1.Message );<br />
}<br />
<br />
DevIntelligence.com - My blog for .Net Developers
|
|
|
|
|
If you load an image from a file, the file remains locked until you call Dispose on the image object.
---
b { font-weight: normal; }
|
|
|
|
|
Hey, howzit, anyone know a good place to get good FREE C# eBooks?
|
|
|
|
|
|
imsathy wrote: gimme ur mail id
If it is a valid free eBook then you can link a URL to it. We don't condone the distribution of copyrighted material. Someone had to write that book and its sales put food on that author's table and a roof over their head. The bottom line is that distributing copyrighted material without the creators consent is theft.
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
saravanan_article@yahoo.com
|
|
|
|
|
I dont know of e-books as such, but there are many good reference sites such as Coding4Fun at http://msdn.com/coding4fun - it contains tutorials to make sample applications ranging from a LCD driver to a GPS-Wired application.
|
|
|
|
|
|
|
can somebody give a simple login validation program, i'm a newbie and i just need it for a refernece.thank you!
|
|
|
|
|
it's very simple
just get the text values of the textboxes that u
have used to accept the username and password and
then check those values with the valid username and password
if they match then the user is allowed to login
else the error message is displayed.
Regards,
Pramod
|
|
|
|
|
thank you! I'll create one and try running it.
|
|
|
|
|
I am having a problem here with my project development. I would be glad if someone can help me out with this. Here comes.
I am trying to look for a way to find back the reference of a created object. Its something like vb6 callbyname but even using callbyname, i still need to have the reference of the object before i can use the callbyname.
Thanks.
MiaoMioa
|
|
|
|
|
can u e more specific about ur problem
if u have created an object u have a reference to it
then y do u need a reference to it again?
|
|
|
|
|
I have something like the below code which might be reasonable to be in this way when there is just a 1,2 class and 1,2 property. But now i am having like 10++ different classed with each class having dozens of properties that i need to get and return the value which the name i can only know when its running coz its classname/propname is from a database table.
*********************************************
Select Case ClassName
Case "Class1"
Select Case PropName
Case "Prop1"
Return clsObj1.Prop1
Case "Prop2"
Return clsObj1.Prop1
End Select
Case "Class2"
Select Case Key
Case "Prop1"
Return clsObj2.Prop1
Case "Prop2"
Return clsObj2.Prop1
End Select
End Select
*********************************************
I was thinking to do something like
*********************************************
Select Case ClassName
Case "Class1"
return myType.InvokeMembers(PropName, Binding.GetProperty, clsObj1, nothing)
Case "Class2"
return myType.InvokeMembers(PropName, Binding.GetProperty, clsObj2, nothing)
End Select
*********************************************
This actually works but only problem is i still need to do this numerous time for each object. Is there somewhat a way to get back the reference of created object by name/type of the object so i do not need to code like this.
Thanks for ur reply.
MiaoMiao
|
|
|
|
|
Here in the select case u check the Classname
so u can create an object of that class and through
that object u can get all the properties of that class
and then do as u wish.
Hope u get it
Regards,
Pramod
|
|
|
|
|
I can get what u mean but problem is am not trying to create a new object from the class name. Actually the object is declared at module level and created during page_load. When a button_click is trigger, i need to get this value from the existing object instead of recreate the object again.
MiaoMiao
|
|
|
|
|
So wht happens to the object that u have created during the page load event
can't u use the same object in the button click event?
Regards,
Pramod
|
|
|
|
|
Yes, ofcoz i can use back the object i create previously but problem is if i have 10 different data object and during the button click, i need to select which object to use, then i would need to have 10 cases rite. It really seems not right to do like this way but i couldn't get any other way to do so. That's why i would like to seek if anyone have meet this problem and have a solution to it.
|
|
|
|
|
Hi All,
I have a DataList with checkbox and a label box in my ItemTemplate and I have used the binding informations for that. In Footer I have a button control.
My query is..when I click that button, I have to get all data that are checked using checkbox.
Can anybody Please help me to do this?
Thanks In Advance,
Regards,
J
|
|
|
|
|
Dear all,
I am using C# to alter a DBF file , Foxpro driver downloaded ,Everything working fine but after running alter query whole DBF format gets corrupted. And I am not able to open it again.
I am adding the code snippet below.Do help me in this regard
public void Alter_table()
{
try
{
string strConnect;
strConnect="User ID=;DSN=;Collating Sequence=MACHINE;Data Source='d:\\22.dbf';Provider=VFPOLEDB.1;Cache Authentication=False;Mask Password=False;persist security info=False;Mode=Share Exclusive;Extended Properties=;Encrypt Password=False";
OleDbConnection dconn=new OleDbConnection();
dconn.ConnectionString = strConnect;
dconn.Open();
OleDbCommand mycmd=new OleDbCommand();
OleDbCommand myCmd = new OleDbCommand("ALTER TABLE 22.dbf ADD COLUMN TEST1 c(10) NULL", dconn);
myCmd.ExecuteNonQuery();
}
catch(OleDbException ex)
{
MessageBox.Show(ex.Message);
}
}
Thanks for any kind of help
Thanks & Regards
Anil Dhiman
Anil Dhiman
GIS Engineer
|
|
|
|
|
Hello.. I am triyng to make a windowsProgram which is like the "search" in windows.. But I don't know where to start? First determine the directories..But how? For example I need to find every directory in C drive and their subfolders ..Then I need to find every text file in that folders and then look for my word.. So anyone any idea how to do that? I found something "directorySearcher" can this be a starting point?
Thanks for advice
Revelation 22:13
|
|
|
|
|
If you read the documentation[^] for the DirectorySearcher class, it reads, "Performs queries against Active Directory." It's for querying Active Directory which is a networking layer, to put it basically. It won't help you.
You'll have to recursively search directories and open files as you stated. This is very expensive, however, and you should consider indexing files instead. You could rely on Windows Desktop Search, which exposes an API[^]. There's lots of other tools out there you can use like Indexing Service, which comes installed in Windows (originally by default, but now you have to install it explicitly but it's a component on the CD/installation media). There's lots and lots of other libraries out there as well.
Indexing only has to traverse files once (and will typically re-index changed or new files). The index is queried and files are returned. This is how web search engines work, too.
If you want to use the slow and expensive recursive search there are several articles available here on Code Project how to do that. Look at the examples in the search http://www.codeproject.com/info/search.asp?cats=2&cats=3&cats=5&cats=6&searchkw=recursive+directory+search[^].
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|