|
|
Hi,
you failed to state what the problem is.
I do have some suggestions for you:
1. ShowDialog() returns a DialogResult, you should check it, and do nothing
when the user cancels.
2. SaveFileDialog class has a public Dispose method, you MUST call it when done;
one way of doing it correctly is with a using statement.
3. OpenFile() returns a stream, which you don't really need. Better use FileName
instead.
4.
Typically file extensions use lower-case, so ".Jpeg" is a bit peculiar. Also
a lot of JPEG files use ".jpg"
5.
You always save in JPEG format, but also accept ".bmp" and ".gif" extensions;
it does not look like a good idea to store a JPEG format in those.
6.
when folder is a string, folder.ToString() does not make sense, just use folder.
7.
Your folder strategy is weird: you come up with a folder value for each image;
if your program runs fast enough two or more images will end up in the same
folder, but when your PC is loaded somehow, they all may use different folders...
You may want to read my timers article.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's 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.
|
|
|
|
|
Sir,
My problem is when i save image image then it save the file but it does not contain any thing means blank file is saved...
now i have made certain changes..
SaveFileDialog slv = new SaveFileDialog();<br />
slv.DefaultExt = "Jpeg";<br />
slv.FileName = DateTime.UtcNow.Ticks.ToString();<br />
slv.Filter = "Jpeg Images|*.jpg|Bmp Images|*.bmp|Gif Images|*.gif";<br />
slv.FilterIndex = 2;<br />
slv.Title = "Save images";<br />
slv.RestoreDirectory = true;<br />
slv.ShowDialog();<br />
System.IO.FileStream fs = (System.IO.FileStream)slv.OpenFile();<br />
for (int I = 0; I < listBoxtextfile.Items.Count; I++)<br />
{<br />
labelBcode.Text = "*" + listBoxtextfile.Items[I].ToString() + "*";<br />
labelBtext.Text = listBoxtextfile.Items[I].ToString();<br />
System.Drawing.Bitmap bi = new System.Drawing.Bitmap(panel1.Width, panel1.Height);<br />
panel1.DrawToBitmap(bi, new System.Drawing.Rectangle(0, 0, panel1.Width, panel1.Height));<br />
bi.Save(slv.OpenFile(), ImageFormat.Jpeg);<br />
bi.Dispose();<br />
} <br />
fs.Close();
|
|
|
|
|
Hi,
you used a stream, that you did not close and did not dispose of.
Reread my previous reply and follow all my suggestions!
Luc Pattyn [Forum Guidelines] [My Articles]
This month's 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.
|
|
|
|
|
filestream that i have used that is already closed....
now i use dispose method to dispose savefiledialog but still it does not save image it just save blank image...
as i want to save image of panel control that is written in my code...
SaveFileDialog slv = new SaveFileDialog();
slv.DefaultExt = "Jpeg";
slv.FileName = DateTime.UtcNow.Ticks.ToString();
slv.Filter = "Jpeg Images|*.jpg|Bmp Images|*.bmp|Gif Images|*.gif";
slv.FilterIndex = 2;
slv.Title = "Save an Image File";
slv.RestoreDirectory = true;
slv.ShowDialog();
System.IO.FileStream fs = (System.IO.FileStream)slv.OpenFile();
System.Drawing.Bitmap bi = new System.Drawing.Bitmap(panel1.Width, panel1.Height);
panel1.DrawToBitmap(bi, new System.Drawing.Rectangle(0, 0, panel1.Width, panel1.Height));
bi.Save(slv.OpenFile(), ImageFormat.Jpeg);
bi.Dispose();
slv.Dispose();
fs.Close();
|
|
|
|
|
SaveFileDialog has a FileName property. You can use this to get the filename that the user has selected from the dialog.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
hi there,
i showed a print dialog before printing to set printing range but when it showed all were disabled... except of "All Pages"
is this problem occuring by printer or .net framework?
my printer is HP 1020 plus
any idea to solve this problem?
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 suggest you read the documentation on PrintDialog Properties; they are ordered
alphabetically and you are lucky, what you need is at the beginning...
Luc Pattyn [Forum Guidelines] [My Articles]
This month's 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.
|
|
|
|
|
oh yeah, i got it, 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
|
|
|
|
|
me making a windows application .i want to add to search options in that .............1. getting records from excel sheet where date matches the user selected date and 2. getting records from excel sheet where batchno(Column in excel) matches the user selected value.
What all ways i can follow ......................................plz help me out .........thanks
Thanks & Regards
Manish Singhal
Software Engineer
Maxworth systems(Delhi)
|
|
|
|
|
you have to use Com Interop Services.
Just Check[^]
Best Regards
-----------------
Abhijit Jana
Microsoft Certified Professional
"Success is Journey it's not a destination"
|
|
|
|
|
ya i know this .........
and using i can have records in my datagid
.............
now i also want to print all this i dont know how to achieve this
...............
another way I am also trying for crytal reports but not achieved success still
................IS there any other way for doing this .............................
thanks a lot
Thanks & Regards
Manish Singhal
Software Engineer
Maxworth systems(Delhi)
|
|
|
|
|
I am trying to copy a listview's items into an array and make a new array by cloning it. Here is the code which I used
ListViewItem[] tempCollection = new ListViewItem[listView1.Items.Count];
listView1.Items.CopyTo(tempCollection,0);
ListViewItem[] clonedCollection = (ListViewItem[])tempCollection.Clone(); I am getting the tempCollection array filled correctly. But after cloning, clonedCollection array is showing all entries as NULL . What I am doing wrong ?
I have to generate a set of PDF files depending on the items selected on the ListView control. Generation of reports is a long running process - I am using BackGroundWorker and running it on DoWork event. As another thread has no access to the GUI elements, I am doing the cloning. I thought of cloning the ListViewItemCollection and using the cloned array. Is there any better approach for this problem ?
|
|
|
|
|
try this :
ListViewItem[] tempCollection = new ListViewItem[listView1.Items.Count];
listView1.Items.CopyTo(tempCollection,0);
ListViewItem[] clonedCollection = new ListViewItem[listView1.Items.Count];
listView1.Items.CopyTo(clonedCollection,0);
hope it will help
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
|
|
|
|
|
Thanks-but this is not cloning.
|
|
|
|
|
yeah but it will work, i think
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
|
|
|
|
|
Why do you think that you have to use the Clone method?
Why are you making a clone that you clone, what's wrong with the first array that you create?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thanks Guffa for replying me.
Guffa wrote: Why do you think that you have to use the Clone method?
As you know, another thread won't be able to access the GUI elements. In my case, I have a ListView where user can select the rows and start the process. So I have to check whether the current row is checked in the thread. When I tried to iterate like listview1.Items it threw "cross thread communication error". So I planned to clone the selected items to a new array and iterate on the cloned array.
|
|
|
|
|
hi ,
can any one tell me how to use css in windows applications (C#).
Thanks ,
CSN
|
|
|
|
|
mrsuman wrote: how to use css in windows applications (C#).
Windows applications don't use CSS. It's for web applications.
|
|
|
|
|
I HAVE USED THIS CODE TO ADD FONT TO MY PROJECT:
Code is inside this link:
http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_22687174.html?sfQueryTermInfo=1+%22c+net%22+ad+applic+file+font+ttf[^]
BUT IT SOME TIME GIVE THIS ERROR
System.ArgumentException was unhandled
Message="Parameter is not valid."
Source="System.Drawing"
StackTrace:
at System.Drawing.FontFamily.GetName(Int32 language)
at System.Drawing.FontFamily.get_Name()
at System.Windows.Forms.Internal.WindowsFont.FromFont(Font font, WindowsFontQuality fontQuality)
at System.Windows.Forms.Internal.WindowsGraphicsCacheManager.GetWindowsFont(Font font, WindowsFontQuality fontQuality)
at System.Windows.Forms.TextRenderer.DrawText(IDeviceContext dc, String text, Font font, Rectangle bounds, Color foreColor, TextFormatFlags flags)
at System.Windows.Forms.Label.OnPaint(PaintEventArgs e)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Label.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at BarcodeLabelPrinter.Program.Main() in E:\BarcodeLabelPrinter\BarcodeLabelPrinter\Program.cs:line 17
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
-------------------------------------------
LINE WHERE THIS ERROR OCCURS
Application.Run(new MainForm());
THIS IS LINE 17 OF PROGRAM.CS
--------------------------------------------
THIS ERROR OCCURS ONLY SOME TIME NOT EVERY TIME WHILE RUNNING APPLICATION....
AND I DID NOT UNDERSTAND THIS ERROR PLEASE HELP ME
|
|
|
|
|
Hello,
this code is with asp.net with VB.Net:
(if items Is nothing then return 0)
but i couldn't write this code with C#.
i'm new to programming...please help me.
thank you.
Hoda
|
|
|
|
|
if (items == null) return 0;
|
|
|
|
|
if(Items==null) return 0;
|
|
|
|
|
Is there a class or method that gets how much memory an object is using? Why I want to is if an object is using more than X ammount of memory, then I'll try to figure out how to make it use less.
Thanks.
|
|
|
|