|
i am trying to pick a image file from open dialog box and send to other user in C#.net
private System.Windows.Forms.OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.RestoreDirectory = true;
openFileDialog1.FileName = "";
openFileDialog1.Filter = "Graphic Interchange Format (*.gif)|*.gif|" +
"JPEG File Interchange Format (*.jpg;*.jpeg)|*.jpg;*.jpeg";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
string filename = openFileDialog1.FileName.Substring(openFileDialog1.FileName.LastIndexOf("\\") + 1);
File.Copy(openFileDialog1.FileName, Application.StartupPath + "\\Temp\\" + filename, true);
string fname = Application.StartupPath + "\\Temp\\" + filename;
if(File.Exists(fname))
WhiteBoard1.iSelected = fname;
FileInfo info = new FileInfo(WhiteBoard1.iSelected);
long filesize = info.Length;
if(filesize>0)
{
WhiteBoard1.strConfid = strConfid;
WhiteBoard1.LoadImage();
}
}
In whiteboard class
public void LoadImage()
{
try
{
Graphics grphs = CreateGraphics();
if(File.Exists(iSelected))
{
Image img1 = Image.FromFile(iSelected);
pict.Image=img1;
}
}
catch(OutOfMemoryException)
{
MessageBox.Show(msg.ToString());
}
}
I get exception as
OutofMemory Exception
|
|
|
|
|
How big is the file ?
asma_panjabi wrote: string filename = openFileDialog1.FileName.Substring(openFileDialog1.FileName.LastIndexOf("\\") + 1);
getting file name ? Use System.IO.Path.GetFileName()
|
|
|
|
|
It doesnt work for any size of file
|
|
|
|
|
sometimes it executes for .jpg but it never takes .gif file. Please some solution for it.
|
|
|
|
|
asma_panjabi wrote:
string filename = openFileDialog1.FileName.Substring(openFileDialog1.FileName.LastIndexOf("\\") + 1);
File.Copy(openFileDialog1.FileName, Application.StartupPath + "\\Temp\\" + filename, true);
string fname = Application.StartupPath + "\\Temp\\" + filename;
Whats all this part about? Why not just use the path that the OpenFileDialog gets?
Also, why do you have a Graphics grphs = CreateGraphics(); it doesn't get used in the code you posted and idealy you shouldn't be using it anyway. If you want to draw to your form you should do it in the OnPaint event.
I mean, that Graphics object could be the thing causing your problems, try moving it out of the try block and see what happens.
My current favourite word is: I'm starting to run out of fav. words!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
I need to send the image from one user to other so i have to copy the file to my drive. So
File.Copy(openFileDialog1.FileName, Application.StartupPath + "\\Temp\\" + filename, true);
string fname = Application.StartupPath + "\\Temp\\" + filename;
I have removed Graphics grphs = CreateGraphics(); from try catch but no gain in that. Plz help
|
|
|
|
|
|
Is it possible to change the order of nodes in treeview control? I wanted to move a node which don't have any child node to one step above. am using c# and winforms dotnetframework is 2.0
|
|
|
|
|
Remove the TreeNode in question from one TreeNodeCollection and put it in another or insert it back into the TreeNodeCollection at a different spot, depending on what "one step above" means. Also look at TreeView.Nodes and TreeNode.Nodes.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
TreeNode parent = myNode;
TreeNode child = parent.Nodes[0];
child.Remove();
parent.Parent.Nodes.Add(child);
child.Nodes.Add(parent);
This statement is false.
|
|
|
|
|
Please give me a code for Binary,Hexadecimal,and Octal Systems to Decimal System in Turbo C or in C++...
|
|
|
|
|
Mark Arjim Parba wrote: Please give me a code ...blah... Turbo C or in C++
Please read point # 1, 2, 3 and 9 in this post[^]
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
|
Why? Whats this got to do with C#.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Have a nice day.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
No. For several reasons. First, wrong forum, and secondly, it does not work like that around here. People will help but not give some lazy slacker code just because they ask for it.
"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
|
|
|
|
|
Hi,
I have build a desktop application and a windows service in c#.net 2.0. I have made a button on main form of application which start or stop windows service. Now, it is working properly in windows XP. But when i install it on windows vista i won't be able to stop or start service. It didn't work. The other thing is that visual studio 2005 doesn't run in debug mode in windows vista. Can anybody help me. Thanx in advance.
regards,
Arslan Ilyas
|
|
|
|
|
Hey Arslan,
This is due to the way Vista handles elevation of privilages on accounts (even ones that do have permissions to do things such as start/stop services). You can verify this by running your application as an Administrator (ie. right click and "Run as administrator" with your admin account). You will also be able to run a debug session after start Visual Studio in the same manor (there are things to be aware of when doing this though).
Please reference this site for more information on these things you're experiencing http://msdn.microsoft.com/en-us/vs2005/aa964140.aspx[^]
Cheers,
-t
|
|
|
|
|
Hi Arslan,
Please make sure that you are meeting the following requirements of Windows Vista OS.
1) Run Visual Studio with elevated administrator permissions.
2) Be a member of the "Administrators" group on the local machine.
3) Right-click the Visual Studio icon and select the "Run as administrator" option from the context menu.
PS: You can create a shortcut to Visual Studio and select the option to always run with elevated administrator permissions. Using this shortcut would be the equivalent of the right-click method described above.
Hope this helps .
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
HI all,
Can someone please help me to convert this VB code to C#.
Thanks!
Private Sub DataGrid1_ItemDataBound
(ByVal sender As Object,
ByVal e As DataGridItemEventArgs)
Handles DataGrid1.ItemDataBound
Dim img As System.Web.UI.WebControls.Image
If e.Item.ItemType = ListItemType.AlternatingItem Or
e.Item.ItemType = ListItemType.Item Then
img = CType(e.Item.Cells(1).Controls(1),
System.Web.UI.WebControls.Image)
img.ImageUrl =
"webform2.aspx?id=" & e.Item.Cells(0).Text
End If
End Sub
EWIN
|
|
|
|
|
There are conversion tools on the web that are free. It's also a good exercise to learn to do this.
The big trick is, there is no C# syntax for 'handles', you need to assign the handler on page load or in the aspx.
Christian Graus
Please read this if you don't understand the answer I've given you
"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 )
|
|
|
|
|
Translation of most VB.NET->C# (and other way around) is pretty simple but with a few things that are specific to one language and not the other. One thing that you could do to learn how one thing is written in language X vs. language Y is look at the direct translation from MSIL.
You can download .NET Reflector from -> http://www.aisto.com/roeder/dotnet/[^] and load in an assembly with the above method in it (must be compilable at this point) and .NET Reflector will allow you to toggle between VB.NET and C#.
.NET Reflector merely looks at the IL and translates to the language of choice from that (in most cases you can simply recompile from it as it does a fairly good job at it).
Hope this helps a little,
Cheers,
-t
|
|
|
|
|
//TODO: INSTANT C# TODO TASK: Insert the following converted event handler wireups at the end of the 'InitializeComponent' method for forms, 'Page_Init' for web pages, or into a constructor for other classes:
DataGrid1.ItemDataBound += DataGrid1_ItemDataBound;
private void DataGrid1_ItemDataBound(object sender, DataGridItemEventArgs e)
{
System.Web.UI.WebControls.Image img = null;
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
{
img = (System.Web.UI.WebControls.Image)(e.Item.Cells[1].Controls[1]);
img.ImageUrl = "webform2.aspx?id=" + e.Item.Cells[0].Text;
}
}
David Anton
http://www.tangiblesoftwaresolutions.com
C++ to C# Converter
C++ to VB Converter
C++ to Java Converter
VB to Java Converter
Java to VB & C# Converter
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: convert VB, C#, or Java to C++/CLI
|
|
|
|
|
Hello everyone,
What are the differences between [Serializable] and [Serializable()]? From IL code, I think they should be the same? So, we have two ways of syntax to write the same thing?
thanks in advance,
George
|
|
|
|
|
I am trying to work out how any of your questions help you to either study or use C#.
I doubt they differ. Look at the MSIL to be sure. If MSDN doesn't tell you how they differ, they don't differ in any meaningful way.
Christian Graus
Please read this if you don't understand the answer I've given you
"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 )
|
|
|
|