|
I want the PDF file's data when it a PDF is opened in IE.
How can I do this using c#.
The COM reference AcroIEHelper.dll is added in my project.
ACROIEHELPERLib.AcroIEHlprObjClass acroIEHlpr = new ACROIEHELPERLib.AcroIEHlprObjClass();
acroIEHlpr is an Object element. From this how can I retrieve the information of PDF opened in IE.
How can I get the text of that PDF file?
|
|
|
|
|
Hi
i have a class called testparams:
[Serializable()]
public class TestParams {
public TestParams() {
}
private string m_filename;
[EditorAttribute(typeof(FileNameEditor), typeof(UITypeEditor))]
public string FileName {
get { return m_filename; }
set { m_filename = value; }
}
}
i use propertygrid and select the object :
TestParams TP = new TestParams();
propertygrid.SelectedObject = TP;
serialization :
private void Save(TestParams obj) {
XmlSerializer xs = new XmlSerializer(typeof(TestParams));
using (FileStream fs = new FileStream(Directory.GetCurrentDirectory() + "\\testparams.xml", FileMode.OpenOrCreate)) {
xs.Serialize(fs, obj);
}
}
}
The problem:
if the user selects the file with the "..." button and i try to serialize TP to xml nothing get written in the file !
when user writes his text freely the xml file is written correctly .
any help will be appreciated
shay
modified on Sunday, June 14, 2009 6:28 AM
|
|
|
|
|
Your use of GetCurrentDirectory is ill-advised. Since the CurrentDirectory can change at any time, without you knowing it, I recommend against using it unless you have a deep understanding of how the current directory is maintained from a system and application points of view.
Member 4086596 wrote: if the user selects the file with the "..." button
Of what control?? Are you showing a SaveFile dialog or what?? Use whatever full path this dialog returns, not CurrentDirectory.
|
|
|
|
|
it seems to me that BitVector32 only supports signed integer
and does not support un-signed integer, what is the reason?
thanks
|
|
|
|
|
Seraph_summer wrote: it seems to me that BitVector32 only supports signed integer
and does not support un-signed integer, what is the reason?
Why does it matter?
If it only supports signed ints (and I'm not sure that it is true, just can't be bothered to test it), it only supports signed ints. Use it if you can use signed ints, don't use it if you can't.
At the end of the day it is a struct, write your own to use signed ints, if you need one.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Becuase the signed integer is CLR compliant, and the unsigned integer is not.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Well I jast have this to classes, I'll write it:
public delegate List< T > LoadChildHandler< T >(int parentId);
public class ObjectBase< T >
{
public int ID { get; set; }
public LoadChildHandler< object > LoadChild;
}
public class Country : ObjectBase< Country >
{
public string CountryName { get; set; }
public List< City > Cities
{
get
{
return (City)LoadChild(ID); <--- Error
}
}
}
Error: Cannot convert type 'System.Collections.Generic.List<object>' to 'G1_OnlineStoreObjects.City'
How can i solve this problem?? advise plz...
C# Developer
|
|
|
|
|
You're trying to cast the objects inside the List, but you're actually casting the List itself. If you're using version 3.5 of the .Net Framework, then you can simply use return LoadChild(ID).Cast<City>();
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
WELL i have done LoadChild(ID).Cast< City >();
but Error occurs aggain: Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<g1_onlinestoreobjects.city>' to 'System.Collections.Generic.List< G1_OnlineStoreObjects.City >'. An explicit conversion exists (are you missing a cast?)
C# Developer
|
|
|
|
|
This is because the extension method Cast() returns an IEnumerable<t>. Just cast it to the property's type and you're done
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
I did not understand
right that: (City)LoadChild(ID).Cast< City >();
but occuers Error again
C# Developer
|
|
|
|
|
LoadChild(ID).Cast<City>() as List<City>;
Besides that, you seem to have a small amount of confusion with List casting. When you cast a List to a City, you do not cast the elements in the List, only the List itself. In order to cast the elements inside the List, you need to use the Cast() method. This method returns an IEnumerable; because List implements IEnumerable, you can cast the List. This does not cast the elements, just the containing class
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
well it's works but there is some another problem like this:
Here is class where I invoked function into delegate
public class CountryDAO : BaseDAO< Country >
{
public override Country Load(int id) //I try to do lazyloading
{
Country country = base.Load(id); //just loads from database to Country class objects
if (country != null)
{
country.LoadChild = LoadCity;// here I invoked it and here occurs error
}
return country;
}
private List< City > LoadCity(int parentId)
{
CityDAO cDao = new CityDAO();
return cDao.LoadList("CountryID=" + parentId.ToString());
}
}
Error: 'System.Collections.Generic.List< G1_OnlineStoreObjects.City > G1_OnlineStoreDAO.CountryDAO.LoadCity(int)' has the wrong return type
what's the matter, why cann't compile it?
I repeat it what you said me to cast bu it is not works again
C# Developer
|
|
|
|
|
This is because you have the wrong return type. The delegate is of type List<Country> LoadChild(int id) , but the delegate you try to convert it to is of type List<City> LoadChild(int id) . That's the main problem, but it seems more architectural than syntactic. Either your delegate type is wrong, City does not inherit from Country, or City and Country don't implement a common interface. Personally, I wouldn't use a generic delegate at all; I'd go for something like this:
public delegate List<City> LoadCitiesDelegate(int countryId);
public class CountryDAO : BaseDAO<Country>
{
public override Country Load(int id)
{
Country country = base.Load(id);
if(country != null)
country.LoadChild = loadCity;
return country;
}
private List<City> LoadCities(int countryId)
{
CityDAO cDao = new CityDAO();
return cDao.LoadList("CountryID=" + countryId.ToString());
}
}
This probably wouldn't compile, but it's a general idea of the way I would personally do it
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Maybe it'll work, but in my project I have many classes and Functions with generics and it's almost impossible to change all
I think I solve this like this, I write it:
public delegate List< T > LoadChildHandler< T >(int parentId);
public class ObjectBase< T >
{
public int ID { get; set; }
}
public class Country : ObjectBase< Country >
{
public LoadChildHandler< City > LoadChild; // I just declare delegate in child class and there are not resist between City and Country, well works fine
public string CountryName { get; set; }
public List< City > Cities
{
get
{
return LoadChild(ID);
}
}
}
and so all I want it to do in a different way...
Now I must dclare this delegate in other classes too, it would be fine to do solve this problem, without declaring in other classes and not such torture
C# Developer
|
|
|
|
|
Hi
I have a Windows form called mainwindow in my project. After it completes what it does, it closes and then recreates itself. But as I have noticed lately it recreates but doesnt't close itself.
Here is my code:
private void RestartAll()
{
depo.multipleformlocation=this.Location;
depo.multipleform = true;
depo.ekrangoruntusuadedi = 0;
this.Hide();
mainwindow _mainwindow = new mainwindow();
_mainwindow.ShowDialog();
this.Close();
Thread.Sleep(Timeout.Infinite);
}
How can I close(destroy) the old form completely and recreate that form? When I don't completely close that old form, because I do this closing and recreating process more than once my App's memory usage gets much higher.
Thanks in advance.
|
|
|
|
|
I am having a little difficulty in understanding where the cause of your problem might lie.
Just to clarify things, what class contains the RestartAll method in the code you posted?
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
RestartAll method is in the mainform class.
|
|
|
|
|
Try this:
private void RestartAll()
{
depo.multipleformlocation=this.Location;
depo.multipleform = true;
depo.ekrangoruntusuadedi = 0;
this.Hide();
using (mainwindow _mainwindow = new mainwindow())
{
_mainwindow.ShowDialog();
}
this.Close();
Thread.Sleep(Timeout.Infinite);
}
Using the using construct 'should' ensure that _mainwindow is disposed.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Thank you. It seems to be working. Should I keep using the Thread.Sleep(Timeout.Infinite); line?
|
|
|
|
|
Try commenting it out and see if everything still works. As you said in your OP it was a temporary solution, and shouldn't be necessary. However, if you still have the old problem after commenting it, the fix hasn't worked and it's back to the drawing-board.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I have commented it and seems like it's still working.
Thank you for your help.
|
|
|
|
|
Excellent.
Try to remember the 'using' construct, whenever you create anything IDisposable. I don't always, particularly when I'm 'just trying something out' and forgetting nearly always causes me problems.
Good Luck!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi,
I don't understand what it is you are doing here. Either this code runs on the GUI thread, and your Sleep(Infinite) hangs it forever, or it runs on some other thread, and it is not allowed to touch any Controls.
I am afraid your approach is completely wrong.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Well, this method doesn't run on the GUI thread but Control.CheckForIllegalCrossThreadCalls is set to false , so all threads are allowed to touch all the Controls.
|
|
|
|