|
Hi Derek,
System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName gives the path of main module. means if you have opened ms -word doc "abc.doc" ,then the code which you have provided will give the path pf winword.exe. it will not give the path of "abc.doc". i need path of "abc.doc", not the path of winword.exe. now as i think requirement is clear to you. once again thanks for your reply.
Balram mallick
|
|
|
|
|
That's VERY difficult. I'll have a think, however I seriously doubt i'll be able to do that. Do you need the path of the open file for all applications (e.g. internet explorer, notepad, etc., or just word)
|
|
|
|
|
yes, now you are getting the point.if you will able to help me that will be really appreciable.Thanks for your co-operation.
balram
|
|
|
|
|
I don't know how you'd do it for all applications, however for office applications there is a specific programming api. Have a look in there. The only other piece of information I can suggest is watching disk activity; there are certainly applications out there that show which processes are accessing which files. That's the best I can do i'm afraid, sorry and good luck, Derek Bartram.
|
|
|
|
|
hi derek
do you have any idea that how i can get path of office applications. i am not getting the api which can show the path of office application.
|
|
|
|
|
|
Hi all!
I have written a method which allows me to access nested properties within objects. The function which I have written returns a PropertyDescriptor , the property component, and property value when given an object and property string.
So for example, if I had an object called "person" it would be possible to access a particular property like:
object component = null, value = null;
PropertyDescriptor desc = person.FindPropertyDescriptor("Occupation.Address.Road", ref component, ref value);
object value = person.Occupation.Address.Road;
Here is the function which I have written:
public static PropertyDescriptor FindPropertyDescriptor(this object obj, string propertyName, ref object nestedComponent, ref object nestedValue)
{
object activeObject = null, nextObject = obj;
PropertyDescriptor propDesc = null;
string propNamePart = "";
int lastIndex = 0, nextIndex = 0;
while (nextIndex != -1)
{
activeObject = nextObject;
nextIndex = propertyName.IndexOf('.', lastIndex);
if (nextIndex != -1)
{
propNamePart = propertyName.Substring(lastIndex, nextIndex - lastIndex);
lastIndex = nextIndex + 1;
}
else
propNamePart = propertyName.Substring(lastIndex, propertyName.Length - lastIndex);
PropertyDescriptorCollection activeProperties = TypeDescriptor.GetProperties(activeObject);
foreach (PropertyDescriptor pDesc in activeProperties)
{
if (pDesc.DisplayName == propNamePart)
{
propDesc = pDesc;
break;
}
}
nextObject = propDesc.GetValue(activeObject);
}
nestedComponent = activeObject;
nestedValue = nextObject;
return propDesc;
}
Is there an easier .NET way of doing the same thing?
Any suggestions would be fantastic!
Lea Hayes
|
|
|
|
|
Personally I always make any dynamically loaded object conform to a set interface, then you don't need to find the various properties of the object, but simple instantiate from the dynamic loader and cast. Makes life a lot easier. I'm wondering if you are trying to reference code not specific to your application, in which case you would have to do it your way.
http://www.codeproject.com/KB/library/dynamicloading.aspx[^] (The way I do it).
|
|
|
|
|
Hi,
I require this functionality for my undo/redo system. When an object property is changed via a property grid control, a property action is created. At the moment I am storing the property component along with the previous and new values. At various stages my program replaces some of these components, and so when the undo/redo action is later executed, the action is not actually undone to the current object. So instead I have done a trial which generates a property name string from the object by enumerating through the parent items of the changed property grid item. Then later this same string can be used to access the property again (using the method I posted previously).
I have read through the article which you have very kindly posted, however I do not think I can apply it for this particular application because some of the properties exist within the .NET runtime, and others are either of a dynamic variety, or exist within my C# code.
Thank you for your advise, it is greatly appreciated.
Lea Hayes
|
|
|
|
|
Crikey sounds complicated! Good luck.
|
|
|
|
|
Hi out there!
I have a question, looking 3 hours for any solution. Currently i'm very
confused. My Problem is quite simply (or isn't?)
I have following problem - i write a C# DLL. Ok, well, not difficult.
But imagine, someone other creates an C# DLL for me and i want to use it in my Project.
now i have an C# DLL and nothing more - now i want to load this DLL dynamic into my program.
like a plug-in... someone can provide some code? i played with System.Reflections but this seems to be very difficult. isn't there anything like DLLImport??? Or does this not work?
i'm open for any help!
Thank you!
FreewareFire is in the House!
|
|
|
|
|
This might be able to help: Google for reflection+.NET+plugin[^]
I looked at the first link and it has some information that might help. I would try to help more, but I am busy as the moment.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
|
Hi
i write this code :
CodeVariableDeclarationStatement cvds_dr = new CodeVariableDeclarationStatement(typeof(System.Data.SqlClient.SqlDataReader), "dr");<br />
method_getData.Statements.Add(cvds_dr);<br />
<br />
CodeVariableDeclarationStatement cvds_dt = new CodeVariableDeclarationStatement(typeof(System.Data.DataTable), "dt");<br />
method_getData.Statements.Add(cvds_dt);
now, i want to create dt.Load(dr); CodeMethodInvokeExpression by this code :
CodeMethodInvokeExpression invoke_dt_load = new CodeMethodInvokeExpression(new CodeVariableReferenceExpression(cvds_dt.Name), "Load", new CodePrimitiveExpression(new CodeVariableReferenceExpression(cvds_dr.Name)));<br />
method_getData.Statements.Add(invoke_dt_load);
but the bold code does not accept and the following error has shown me :
Invalid Primitive Type: System.CodeDom.CodeVariableReferenceExpression. Consider using CodeObjectCreateExpression
line of code that show error messsage is :
provider.GenerateCodeFromCompileUnit(compileUnit, tw, new CodeGeneratorOptions());
|
|
|
|
|
Hi!
I am using a DataGridView component in a simple C# application. I want to suppress the component to be initialized to only have 10 rows and no eleventh row is created what so ever. I have tried but have run out of ideas.
I will appreciate any kind of guidelines.
With thanks in advance.
|
|
|
|
|
I have an application that I was thinking would work much better if it could store it's files in a format similar to the OOXML concept. In other words, pack separate parts into a single ZIP file because it's a PITA to deal with my xml files and the external images that are associated with it.
It looks, to me, like you could use the .NET System.IO.Packaging namespaces to achieve this but I can find any examples that aren't writing something other than an OOXML or XPS file. Does anybody have some pointers on this? Am I barking up the wrong tree?
Cheers!
|
|
|
|
|
|
KaptinKrunch wrote: Have you read this page??
Yes I have. I was hoping to see an example that isn't creating an OOXML or XPS package to save me from any potential pitfalls.
I think I can use it, but I'll need to do some serious surgery on my application and I'll need to think very carefully about how much I should divide my file up and what the relationships should be.
|
|
|
|
|
Hi folks!
I'm coding a very simple Windows Application on VS 2005 (C#) in order to see the records of Customers table of Northwind database.
This Windows Application works fine by "Debugging" on VS 2005 enviroment with "Windows Authentication" to connect to the database.
Now, I thinking to deploy the application, so I created an "Application Role" in the Northwind database.
But, how do I use that Application Role in my application? How do I invoke it?
Can somebody help me?
(Details and reference to step by step guides will be appreciated.)
--
Adrián Córdoba
|
|
|
|
|
|
KaptinKrunch wrote: I'm waiting for the day google does not have the answer.
http://msdn2.microsoft.com/en-us/library/5k850zwb.aspx[^]
KaptinKrunch:
I'm talking about to use "Application Roles" (from MS SQL Server's roles) in my application for connecting to the database. I'm not talking about roles for my applicaton.
In other words, how do I modify my application (now using Windows Authentication) to connect to the database by using an application role that I created in the database (SQL Server Management Studio)?
I saw several sites found by mean Google, but I didn't find a good guide for this purpose.
Anyway, thank you for your answer.
--
Adrián Córdoba
|
|
|
|
|
Can any plz temme dat ..how to put skins/template in winforms (C#'s desktop application )
asd
|
|
|
|
|
Unless you're using WPF, you have to buy it. Period. End of story. That's all she wrote. The fat lady sang already.
First - Buy this.[^]
Then - Read all of it's documentation thoroughly.
After That - come back with code problems (if you have them )
"Run for your life from any man who tells you that money is evil. That sentence is the leper's bell of an approaching looter." --Ayn Rand
|
|
|
|
|
hhani wrote: how to put skins/template in winforms (C#'s desktop application )
You've asked this question before[^] and you were given an answer. Asking the question again will not change the answer.
What don't you like about the answer you were given already?
|
|
|
|
|
Colin Angus Mackay wrote: Asking the question again will not change the answer.
You must not of heard of Heisenberg's uncertainty principle.
|
|
|
|