Below; I have 2 classes (forms), Namely, "PrintOneEmploy ee" and "DeleteOne" . In class "PrintOneEmploy ee";
I want to declare a variable with name of "fileName" to contain the name of the file "Main\\_1Main.t xt".
Later on, when I wanted to access the variable "fileName" in the other class, namely, "DeleteOne" . The
compiler show an error that the variable is undeclared. What should I do to access the variable "fileName"
in the the other class "DeleteOne" ? I am aware of the scope of the variable inside the brackets,
but I am confused about the scope of the different classes.
/*************** *************** *************** *************/
/*************** *************** *************** *************** *********/
--
Thanks
Allen
I want to declare a variable with name of "fileName" to contain the name of the file "Main\\_1Main.t xt".
Later on, when I wanted to access the variable "fileName" in the other class, namely, "DeleteOne" . The
compiler show an error that the variable is undeclared. What should I do to access the variable "fileName"
in the the other class "DeleteOne" ? I am aware of the scope of the variable inside the brackets,
but I am confused about the scope of the different classes.
/*************** *************** *************** *************/
Code:
#pragma once
#using <System.dll>
#using <System.Windows.Forms.dll>
#using <System.Drawing.dll>
#include "DeleteOne.h"
#include "Time.h"
#using <mscorlib.dll>
using namespace System;
using namespace System::IO;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Drawing::Printing;
namespace TimeTracking
{
public ref class PrintOneEmployee : public System::Windows::Forms::Form
{
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
{
streamToPrint = gcnew StreamReader( "Main\\_1Main.txt" );
String^ fileName = "Main\\_1Main.txt"String^ fileName;
}
}
};
}
Code:
#pragma once
#include "Time.h"
//#include "PrintOneEmployee.h"
#using <mscorlib.dll>
using namespace System;
using namespace System::IO;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
namespace TimeTracking
{
public ref class DeleteOne : public System::Windows::Forms::Form
{
private: System::Void OkBotton_Click(System::Object^ sender, System::EventArgs^ e)
{
FileInfo^ fi = gcnew FileInfo(FileName);
fi->Delete();
}
};
}
--
Thanks
Allen
Comment