Compieler verwendet falsches class und namespace
-
Hallo zusammen!
Ich habe folgendes Problem:
bool CanBeWrited(DirectoryInfo *dir) { try { dir->Attributes ^= System::IO::FileAttributes::ReadOnly; return true; } catch(...) { return false; } }
Beim compilieren bekomme ich dieses Fehler:
error C2664: 'System::IO::FileSystemInfo::set_Attributes': Konvertierung des Parameters 1 von 'int' in 'System::IO::FileAttributes' nicht möglich
Habe bischen nachgeforscht... Compiller verwechselt System::IO::FileAttributes::ReadOnly mit System::Web::UI::HtmlTextWriterAttribute::ReadOnly
Man sieht es auf dem Bild wenn ich mit Maus über ReadOnly fahre
http://forum.vitaligraf.de/upload/pix/compieler-fehler.pngWas kann ich dagegen unternehmen ?
-
Also, bei mir lässt sich folgendes Problemlos compilieren...
System::IO::FileAttributes a = System::IO::FileAttributes::Normal; a = a ^ System::IO::FileAttributes::Archive;
Dagegen geht folgendes nicht!
a ^= System::IO::FileAttributes::Archive;
Also, ersetze mal das ^= durch ein explizites ^; und dann schau mal was passiert.
-
Habe es so gemacht:
dir->Attributes = dir->Attributes ^ System::IO::FileAttributes::ReadOnly;
kommt selbe Fehler.
Mich wundert das er System::Web::UI::HtmlTextWriterAttribute::ReadOnly verwenden will. Warum?
-
und das hat auch nicht geholfen:
System::IO::FileAttributes a = dir->Attributes; a = a ^ System::IO::FileAttributes::ReadOnly; dir->Attributes = a;
-
Hast Du irgend ein kleines vollständiges Beispiel-Projekt, wo dieser Fehler auftritt?
-
Ich kann das machen...
-
So ... fertig!
www.vitaligraf.de/compiler-fehler.7z
-
Sag doch gleich dass Du VC2003 verwendest...
Mach es so:System::IO::FileAttributes fa = (System::IO::FileAttributes) (_d->Attributes ^ System::IO::FileAttributes::ReadOnly); _d->Attributes = fa;
-
Danke !!!