|
You may want to re-read my answer
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Hi Pete,
The code:
File.Copy(baseDir, @"c:\desiredlocation"); throws exception!
Exception type:
IOException
Exception Details:
The target file "C:\desiredlocation" is a diretory, not a file.
PS: I want to copy the exe file namely 'ConsoleApplication1.exe' to C:\desiredlocation and not the entire project.
Any ideas?
|
|
|
|
|
Hey, I read the documentation for you!
public static void Copy (
string sourceFileName,
string destFileName
)
Parameters
sourceFileName
The file to copy.
destFileName
The name of the destination file. This cannot be a directory or an existing file.
Alan.
|
|
|
|
|
Hmm, copy the currently running executable..... we had another guy here recently trying to achieve the same.
|
|
|
|
|
Copying the current execuable is a very difficult task and indeed a difficult task. I dont care who that another guy was and what he wanted to achieve.
|
|
|
|
|
You are the other guy you twat!
|
|
|
|
|
Why do you have to copy the current executable to another location? What kind of application are you writing?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
This user goes by another name, Rajdeep.Net, who has been repeatidly asking for code or help with intentions to create malicious and/or harmful applications. His previous posts clearly indicate it, and it's undeniable. After so many complaints from users here, he resorted to reregistering under a different name, specifying a different country of origin.
I hate him.
|
|
|
|
|
I had the same doubt as well. I could make it out clearly from the way he forms his query (and also the query itself). Don't give him too much importance to hate him. Just ignore him, he will go away. He has to.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
ShreeR.Bhattacharjee wrote: Check this out guys!
Give your thread a 'meaningful' title.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
public class SomeEnumAttribute: DescriptionAttribute
{
public override string Description
{
get
{
string resFile;
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (Assembly assembly in assemblies)
{
Type type = assembly.GetType("/*The type defined needs to go in here*/");
if (type != null)
{
resFile = assembly.GetName().Name ;
break;
}
}
}
}
}
public enum MyEnum
{
[SomeEnumAttribute("abc")]
abc = 0,
[SomeEnumAttribute("def")]
def,
[SomeEnumAttribute("ghi")]
ghi,
[SomeEnumAttribute("ghi1")]
ghi1
}
What we ought to do is this: Get the fully qualified name of the enum(MyEnum) and replace it with "/*The type defined needs to go in here*/" in the snippet above.
Can someone help with this.
Note: This class is defined in another binary.
<italics>In another words the question is can we get the enum name(type name) in which the attribute is being used.
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
modified on Thursday, June 4, 2009 4:11 AM
|
|
|
|
|
typeof(MyEnum).FullName
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Thanks for the reply.
The problem is that this MyEnum is defined elsewhere in another binary and not in this one.
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
Then you need to call the code snippet I gave in that binary. If you don't have access to it, the format is namespace.MyEnum . Just make sure you know which namespace it's in
An alternative is to scan the entire assembly, and wait until you get a Type which has IsEnum set, and has a Name of MyEnum. Then, note down the FullName property, and use that when you use Assembly.GetType. Don't do the scanning in your finished program though - just whip up a small testbed to give you the FullName, and use that in your actual code
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Just to make it clear - Are you assuming that you have the name of the Enum, in our case MyEnum, that can be searched in the assembly. The problem still remains on getting the name of the enum in the DescriptionAttribute derived class so that I can use it to locate the assembly in which it is defined.
Thanks for the help...
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
I'm still assuming that you want to get the type of MyEnum. The second paragraph shows how you could retrieve the full name. If you already know the full name (including namespace - you may be able to find this out using Red Gate's .Net Reflector), then you can pass this to Assembly.GetType
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
But to get the type we should have the name (namespace.MyEnum), which I don't have. I want to make it available in the DescriptionAttribute derived class.
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
Exactly. If you open the file in .Net Reflector, then you can search for MyEnum and get the namespace from there. But why not just make Type of MyEnum available in the DescriptionAttribute derived class, instead of the name; that way you can save the time it takes to call Assembly.GetType. As long as you know how to create your own attribute which accepts a Type instantiation and has a Type property, and how to use Assembly.GetCustomAttributes, you have the Type
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Are you trying to write a generic attribute or one that only works with MyEnum ? If it's the former, I can't see any way around passing typeof(MyEnum) to the constructor of SomeEnumAttribute.
|
|
|
|
|
there is a way though:
SomeEnum[Description(typeof(MyEnum),"value")]
write a constructor in SomeEnum attribute derived class and lo and behold you have the MyEnum type in the attribute class.
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
Um, isn't that what I said in my previous post?
I can't see any way around passing typeof(MyEnum) to the constructor of SomeEnumAttribute.
|
|
|
|
|
Hi
I am unable to connect to oracle using c# , its giving me exception like "Connection not open" and sometimes TNS error , i have tried several methods which are as under
string oradb = "Data Source=(DESCRIPTION="
+ "(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=ORASRVR) (PORT=1521)))"
+ "(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=mariam)));"
+ "User Id=system;Password=mariam;";
OracleConnection conn = new OracleConnection(oradb);
conn.Open();
and
string strCon = "Driver={Microsoft ODBC for Oracle};SERVER = 10.17.18.62; Uid=system;Pwd=mariam;";
OdbcConnection odbc_Con = new OdbcConnection("Driver={Microsoft ODBC for Oracle};Server=DEDICATED; UID=system;PWD=mariam;");
odbc_Con.ConnectionString = "Driver={Microsoft ODBC for Oracle};Server=DEDICATED; UID=system;PWD=mariam;";
odbc_Con.Open();
and
string strCon = "Driver={Microsoft ODBC for Oracle};SERVER = 10.17.18.62; Uid=system;Pwd=mariam;";
OleDbConnection oracleConn = new OleDbConnection();
oracleConn.ConnectionString = "Provider=\"OraOLEDB.Oracle.1\";User ID=system;Password=mariam; Data Source=XE; Extended Properties=\"\"; Persist Security Info=False ";
oracleConn.Open();
help will be appreciated
regards,
|
|
|
|
|
Hi friends,
I want to get the path of the current executable using C#.
In VB.NET, we do it something like this:
Dim aPath As String = Application.ExecutablePath()
Was wondering how to do this using C#!
Help needed,
ShreeR
|
|
|
|
|
string aPath = Application.ExecutablePath;
maybe that's what you want
Life goes very fast. Tomorrow, today is already yesterday.
modified on Thursday, June 4, 2009 4:04 AM
|
|
|
|
|
There's no need for the brackets; ExecutablePath is a property, not a method
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|