Creating a folder in %appdata%

  • (2 Pages)
  • +
  • 1
  • 2

15 Replies - 12297 Views - Last Post: 19 August 2012 - 06:24 AM

#1 Lukee9  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 37
  • Joined: 15-August 12

Creating a folder in %appdata%

Posted 15 August 2012 - 05:05 AM

Ok! Well, I haven't been doing C++ long, so i'm not a god at it. But i'm trying to create an install wizard for my friend who is making a client for this game called Minecraft.
There are 2 buttons. One of them starts the loading, then the other goes to the next page. I use an if statement for the second button, which says basically says 'if checkbox ticked, make backup folder'. I haven't actually done any of the coding for backing up or moving the files yet. So its just basically a loading bar, that creates a folder. The only thing is the folder doesn't get created (when I the checkbox is ticked).
Here's the code:

#pragma once
#include "Finished.h"
#include <stdio.h>
#include <stdlib.h>
#include <direct.h>
#include <time.h>
namespace ProgressbarTutorial {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;

	/// <summary>
	/// Summary for Form1
	///
	/// WARNING: If you change the name of this class, you will need to change the
	///          'Resource File Name' property for the managed resource compiler tool
	///          associated with all .resx files this class depends on.  Otherwise,
	///          the designers will not be able to interact properly with localized
	///          resources associated with this form.
	/// </summary>
	public ref class Form1 : public System::Windows::Forms::Form
	{
	public:
		Form1(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}
	private: System::Windows::Forms::ProgressBar^  progressBar1;
	protected: 
	private: System::Windows::Forms::Button^  button1;
	private: System::Windows::Forms::Timer^  timer1;
	private: System::Windows::Forms::Label^  label1;
	private: System::Windows::Forms::Button^  button2;
	private: System::Windows::Forms::CheckBox^  checkBox1;
	private: System::ComponentModel::IContainer^  components;

	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>


#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
			this->components = (gcnew System::ComponentModel::Container());
			System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
			this->progressBar1 = (gcnew System::Windows::Forms::ProgressBar());
			this->button1 = (gcnew System::Windows::Forms::Button());
			this->timer1 = (gcnew System::Windows::Forms::Timer(this->components));
			this->label1 = (gcnew System::Windows::Forms::Label());
			this->button2 = (gcnew System::Windows::Forms::Button());
			this->checkBox1 = (gcnew System::Windows::Forms::CheckBox());
			this->SuspendLayout();
			// 
			// progressBar1
			// 
			this->progressBar1->Location = System::Drawing::Point(12, 211);
			this->progressBar1->Name = L"progressBar1";
			this->progressBar1->Size = System::Drawing::Size(477, 53);
			this->progressBar1->TabIndex = 0;
			this->progressBar1->Click += gcnew System::EventHandler(this, &Form1::progressBar1_Click);
			// 
			// button1
			// 
			this->button1->Location = System::Drawing::Point(12, 122);
			this->button1->Name = L"button1";
			this->button1->Size = System::Drawing::Size(77, 55);
			this->button1->TabIndex = 1;
			this->button1->Text = L"Begin Download";
			this->button1->UseVisualStyleBackColor = true;
			this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
			// 
			// timer1
			// 
			this->timer1->Tick += gcnew System::EventHandler(this, &Form1::timer1_Tick);
			// 
			// label1
			// 
			this->label1->AutoSize = true;
			this->label1->BackColor = System::Drawing::Color::Transparent;
			this->label1->ForeColor = System::Drawing::SystemColors::ActiveCaptionText;
			this->label1->Location = System::Drawing::Point(12, 180);
			this->label1->Name = L"label1";
			this->label1->Size = System::Drawing::Size(0, 13);
			this->label1->TabIndex = 2;
			this->label1->Click += gcnew System::EventHandler(this, &Form1::label1_Click);
			// 
			// button2
			// 
			this->button2->Location = System::Drawing::Point(412, 122);
			this->button2->Name = L"button2";
			this->button2->Size = System::Drawing::Size(77, 55);
			this->button2->TabIndex = 3;
			this->button2->Text = L"Continue...";
			this->button2->UseVisualStyleBackColor = true;
			this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
			// 
			// checkBox1
			// 
			this->checkBox1->AutoSize = true;
			this->checkBox1->Location = System::Drawing::Point(312, 99);
			this->checkBox1->Name = L"checkBox1";
			this->checkBox1->Size = System::Drawing::Size(177, 17);
			this->checkBox1->TabIndex = 4;
			this->checkBox1->Text = L"Save a backup of minecraft.jar\?";
			this->checkBox1->UseVisualStyleBackColor = true;
			this->checkBox1->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox1_CheckedChanged);
			// 
			// Form1
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(501, 276);
			this->Controls->Add(this->checkBox1);
			this->Controls->Add(this->button2);
			this->Controls->Add(this->label1);
			this->Controls->Add(this->button1);
			this->Controls->Add(this->progressBar1);
			this->Icon = (cli::safe_cast<System::Drawing::Icon^  >(resources->GetObject(L"$this.Icon")));
			this->Name = L"Form1";
			this->Text = L"LucidHacks - Install";
			this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
			this->ResumeLayout(false);
			this->PerformLayout();

		}
#pragma endregion
	private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
				 this->timer1->Start();
			 }
	private: System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e) {
				 				 				 int iSecret;

  /* initialize random seed: */
  srand ( time(NULL) );

  /* generate secret number: */
  iSecret = rand() % 3 + 1;
				 this->progressBar1->Increment(iSecret);
			 }
	private: System::Void label1_Click(System::Object^  sender, System::EventArgs^  e) {
			 }
private: System::Void progressBar1_Click(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
			 if ((checkBox1->Checked == true) && (this->progressBar1->Value == 100));
{
{
										 mkdir("%appdata%\.minecraft\backup");
}
}
	
if (this->progressBar1->Value == 100)
	Finished().ShowDialog(); 
else if (this->progressBar1->Value == 0)
	MessageBox::Show("Program must load first!");


		 }
private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
		 }
private: System::Void checkBox1_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
		 }
};
}




Here are some pictures:

Picture 1, the install wizard with the checkbox ticked.
Posted Image

Picture 2, showing the final page, after the backup folder should have been created.
Posted Image

Picture 3, showing where the backup folder should of been created (but its not :C )
Posted Image

Is This A Good Question/Topic? 0
  • +

Replies To: Creating a folder in %appdata%

#2 snoopy11  Icon User is online

  • Engineering ● Software
  • member icon

Reputation: 765
  • View blog
  • Posts: 2,227
  • Joined: 20-March 10

Re: Creating a folder in %appdata%

Posted 15 August 2012 - 06:18 AM

You would have to use

CreateDirectory

Which is in Windows.h

Where do you use that in your
current code ?

Snoopy
Was This Post Helpful? 0
  • +
  • -

#3 Lukee9  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 37
  • Joined: 15-August 12

Re: Creating a folder in %appdata%

Posted 15 August 2012 - 06:32 AM

View Postsnoopy11, on 15 August 2012 - 06:18 AM, said:

You would have to use

CreateDirectory

Which is in Windows.h

Where do you use that in your
current code ?

Snoopy

I'm not using Windows.h currently. How would one go about doing this? D:
Was This Post Helpful? 0
  • +
  • -

#4 snoopy11  Icon User is online

  • Engineering ● Software
  • member icon

Reputation: 765
  • View blog
  • Posts: 2,227
  • Joined: 20-March 10

Re: Creating a folder in %appdata%

Posted 15 August 2012 - 08:19 AM

include <Windows.h>


Usage :-

public:
void CreateDirectory(
String^ path,
int posixPermissions
)



path is the full path to the directory to be
created.

posixPermissions the security permissions
For the directory "0700" which has to be
given as 0xc10

Snoopy.
Was This Post Helpful? 1
  • +
  • -

#5 RudiVisser  Icon User is offline

  • .. does not guess solutions
  • member icon

Reputation: 1002
  • View blog
  • Posts: 3,562
  • Joined: 05-June 09

Re: Creating a folder in %appdata%

Posted 15 August 2012 - 08:28 AM

Well since it's C++/CLI (which seems overkill in my opinion for this app, why not just use C#?), you can use the System.IO namespace, and use Directory->Create().

This post has been edited by RudiVisser: 15 August 2012 - 08:28 AM

Was This Post Helpful? 0
  • +
  • -

#6 Lukee9  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 37
  • Joined: 15-August 12

Re: Creating a folder in %appdata%

Posted 15 August 2012 - 10:19 AM

View Postsnoopy11, on 15 August 2012 - 08:19 AM, said:

include <Windows.h>


Usage :-

public:
void CreateDirectory(
String^ path,
int posixPermissions
)



path is the full path to the directory to be
created.

posixPermissions the security permissions
For the directory "0700" which has to be
given as 0xc10

Snoopy.

Sorry but i don't really understand the bit about the permissions, I can't find a 0700 or 0xc10 directory D: do i need to change what you put there, or should my code just say:
public:
void CreateDirectory(
String^ %appdata%\.minecraft\backup,
int posixPermissions
)
Thanks for your replies so far btw :)
Was This Post Helpful? 0
  • +
  • -

#7 Lukee9  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 37
  • Joined: 15-August 12

Re: Creating a folder in %appdata%

Posted 15 August 2012 - 12:07 PM

Also i think its not working because of something to do with %appdata%, as in you can't use it in your path.
Was This Post Helpful? 0
  • +
  • -

#8 RudiVisser  Icon User is offline

  • .. does not guess solutions
  • member icon

Reputation: 1002
  • View blog
  • Posts: 3,562
  • Joined: 05-June 09

Re: Creating a folder in %appdata%

Posted 16 August 2012 - 02:13 AM

Provided I can remember the C++/CLI syntax well enough, this should work fine:
String ^ appDataDir = System::IO::Environment::GetFolderPath(Environment::SpecialFolder::LocalApplicationData); // Or use GetEnvironmentVariable(L"APPDATA")
String ^ newDir = System::IO::Path::Combine(appDataDir, L".minecraft/backup");
System::IO::Directory::CreateDirectory(newDir);


Was This Post Helpful? 0
  • +
  • -

#9 Lukee9  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 37
  • Joined: 15-August 12

Re: Creating a folder in %appdata%

Posted 16 August 2012 - 09:25 AM

View PostRudiVisser, on 16 August 2012 - 02:13 AM, said:

Provided I can remember the C++/CLI syntax well enough, this should work fine:
String ^ appDataDir = System::IO::Environment::GetFolderPath(Environment::SpecialFolder::LocalApplicationData); // Or use GetEnvironmentVariable(L"APPDATA")
String ^ newDir = System::IO::Path::Combine(appDataDir, L".minecraft/backup");
System::IO::Directory::CreateDirectory(newDir);


Thanks for your help, but still not working.
heres the errors:


Error 6 error C3083: 'Environment': the symbol to the left of a '::' must be a type c:\users\luke\documents\visual studio 2010\projects\progressbar tutorial\progressbar tutorial\Form1.h 174
Error 7 error C2039: 'GetFolderPath' : is not a member of 'System::IO' c:\users\luke\documents\visual studio 2010\projects\progressbar tutorial\progressbar tutorial\Form1.h 174
Error 8 error C3861: 'GetFolderPath': identifier not found c:\users\luke\documents\visual studio 2010\projects\progressbar tutorial\progressbar tutorial\Form1.h 174


not sure if i have all the namespaces i should be using, heres the namespaces:
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System.IO;
and all the included files:
#include "Finished.h"
#include <stdio.h>
#include <stdlib.h>
#include <direct.h>
#include <time.h>
#include <windows.h>
Was This Post Helpful? 0
  • +
  • -

#10 Lukee9  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 37
  • Joined: 15-August 12

Re: Creating a folder in %appdata%

Posted 17 August 2012 - 06:18 AM

View PostRudiVisser, on 16 August 2012 - 02:13 AM, said:

Provided I can remember the C++/CLI syntax well enough, this should work fine:
String ^ appDataDir = System::IO::Environment::GetFolderPath(Environment::SpecialFolder::LocalApplicationData); // Or use GetEnvironmentVariable(L"APPDATA")
String ^ newDir = System::IO::Path::Combine(appDataDir, L".minecraft/backup");
System::IO::Directory::CreateDirectory(newDir);


Your code was broken, so I fixed it and the program works, but the folder is still not being created, I've gone through with breakpoints and it runs all the right code, but no folder is actually created, I checked to see if the folder actually gets created, but there isn't a single folder called backup that gets created.
Was This Post Helpful? 0
  • +
  • -

#11 Lukee9  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 37
  • Joined: 15-August 12

Re: Creating a folder in %appdata%

Posted 17 August 2012 - 06:41 AM

View PostLukee9, on 17 August 2012 - 06:18 AM, said:

View PostRudiVisser, on 16 August 2012 - 02:13 AM, said:

Provided I can remember the C++/CLI syntax well enough, this should work fine:
String ^ appDataDir = System::IO::Environment::GetFolderPath(Environment::SpecialFolder::LocalApplicationData); // Or use GetEnvironmentVariable(L"APPDATA")
String ^ newDir = System::IO::Path::Combine(appDataDir, L".minecraft/backup");
System::IO::Directory::CreateDirectory(newDir);


Your code was broken, so I fixed it and the program works, but the folder is still not being created, I've gone through with breakpoints and it runs all the right code, but no folder is actually created, I checked to see if the folder actually gets created, but there isn't a single folder called backup that gets created.

The fixed code is:
			 if ((checkBox1->Checked == true) && (this->progressBar1->Value == 100))
{
String ^ appDataDir = Environment::GetFolderPath(Environment::SpecialFolder::LocalApplicationData); // Or use GetEnvironmentVariable(L"APPDATA")
String ^ newDir = Path::Combine(appDataDir, L".minecraft/backup");
Directory::CreateDirectory(newDir);
}

Was This Post Helpful? 0
  • +
  • -

#12 RudiVisser  Icon User is offline

  • .. does not guess solutions
  • member icon

Reputation: 1002
  • View blog
  • Posts: 3,562
  • Joined: 05-June 09

Re: Creating a folder in %appdata%

Posted 17 August 2012 - 07:48 AM

I'm not sure what's actually changed there apart from the namespace removal?

Anyway, does .minecraft exist? You would have to call Directory::Create on both folders individually if not, it won't automatically create nested folders.
Was This Post Helpful? 0
  • +
  • -

#13 Lukee9  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 37
  • Joined: 15-August 12

Re: Creating a folder in %appdata%

Posted 17 August 2012 - 11:02 AM

View PostRudiVisser, on 17 August 2012 - 07:48 AM, said:

I'm not sure what's actually changed there apart from the namespace removal?

Anyway, does .minecraft exist? You would have to call Directory::Create on both folders individually if not, it won't automatically create nested folders.

It does exist, just look at the picture i posted above (the path at the top)
Posted Image
I was wondering if I should use CreateSubdirectory instead? Also. Does LocalAppdataFolder lead to AppData? or Appdata\Roaming. Because %appdata% leads to Roaming. If you get what I'm saying?

View PostLukee9, on 17 August 2012 - 10:56 AM, said:

View PostRudiVisser, on 17 August 2012 - 07:48 AM, said:

I'm not sure what's actually changed there apart from the namespace removal?

Anyway, does .minecraft exist? You would have to call Directory::Create on both folders individually if not, it won't automatically create nested folders.

It does exist, just look at the picture i posted above (the path at the top)
Posted Image
I was wondering if I should use CreateSubdirectory instead? Also. Does LocalAppdataFolder lead to AppData? or Appdata\Roaming. Because %appdata% leads to Roaming. If you get what I'm saying?

Anyway. If we can't find a solution to this. I can also do the folder creation through VB.net seeing as I'm pro with that

Also (sorry about keep posting, but there's no edit button -_- ), whats the difference between '\\' and '/' in the path?
Was This Post Helpful? 0
  • +
  • -

#14 snoopy11  Icon User is online

  • Engineering ● Software
  • member icon

Reputation: 765
  • View blog
  • Posts: 2,227
  • Joined: 20-March 10

Re: Creating a folder in %appdata%

Posted 17 August 2012 - 11:57 PM

Hi,

I see your still having problems

full code example solution below

type directory to be created in edit box press create directory button, simple
I also dont have a %appdata% on my computer so have no idea what you meanby that. I do have a %USERPROFILE% is this what you mean ?

Form1.h

#pragma once
#include <cstring>

namespace clrprogress {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;
	using namespace System::Security::AccessControl;
	/// <summary>
	/// Summary for Form1
	/// </summary>
	public ref class Form1 : public System::Windows::Forms::Form
	{
	public:
		Form1(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}
	private: System::Windows::Forms::Button^  button1;
	private: System::Windows::Forms::TextBox^  textBox1;
	protected: 

	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
			this->button1 = (gcnew System::Windows::Forms::Button());
			this->textBox1 = (gcnew System::Windows::Forms::TextBox());
			this->SuspendLayout();
			// 
			// button1
			// 
			this->button1->Location = System::Drawing::Point(13, 33);
			this->button1->Name = L"button1";
			this->button1->Size = System::Drawing::Size(106, 23);
			this->button1->TabIndex = 0;
			this->button1->Text = L"Create Directory";
			this->button1->UseVisualStyleBackColor = true;
			this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
			// 
			// textBox1
			// 
			this->textBox1->Location = System::Drawing::Point(11, 78);
			this->textBox1->Name = L"textBox1";
			this->textBox1->Size = System::Drawing::Size(234, 20);
			this->textBox1->TabIndex = 1;
			// 
			// Form1
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(284, 262);
			this->Controls->Add(this->textBox1);
			this->Controls->Add(this->button1);
			this->Name = L"Form1";
			this->Text = L"Form1";
			this->ResumeLayout(false);
			this->PerformLayout();

		}
#pragma endregion
	private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {

              String^ text;
			  text = textBox1-> Text;
			 
			  DirectorySecurity^ Secure;
			  
			  System::IO::Directory::CreateDirectory(text,Secure);
			 }
	};
}





clrprogress.cpp

// clrprogress.cpp : main project file.

#include "stdafx.h"
#include "Form1.h"

using namespace clrprogress;

[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
	// Enabling Windows XP visual effects before any controls are created
	Application::EnableVisualStyles();
	Application::SetCompatibleTextRenderingDefault(false); 

	// Create the main window and run it
	Application::Run(gcnew Form1());
	return 0;
}




Snoopy.

This post has been edited by snoopy11: 18 August 2012 - 02:16 AM

Was This Post Helpful? 0
  • +
  • -

#15 snoopy11  Icon User is online

  • Engineering ● Software
  • member icon

Reputation: 765
  • View blog
  • Posts: 2,227
  • Joined: 20-March 10

Re: Creating a folder in %appdata%

Posted 18 August 2012 - 07:17 PM

Ahh,

I found out how to get your current appdata path..

you have to use SHGetFolderPath

I have revised the code a little..

It should now do what you want..

On an aside there are many free install programs available

Why write your own ?

anyway...

Form1.h

#pragma once
#include <cstring>
#include <shlobj.h>
#pragma comment(lib, "shell32.lib")

namespace clrprogress {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;
	using namespace System::Security::AccessControl;
	/// <summary>
	/// Summary for Form1
	/// </summary>
	public ref class Form1 : public System::Windows::Forms::Form
	{
	public:
		Form1(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}
	private: System::Windows::Forms::Button^  button1;
	private: System::Windows::Forms::TextBox^  textBox1;
	protected: 

	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
			this->button1 = (gcnew System::Windows::Forms::Button());
			this->textBox1 = (gcnew System::Windows::Forms::TextBox());
			this->SuspendLayout();
			// 
			// button1
			// 
			this->button1->Location = System::Drawing::Point(13, 33);
			this->button1->Name = L"button1";
			this->button1->Size = System::Drawing::Size(106, 23);
			this->button1->TabIndex = 0;
			this->button1->Text = L"Create Directory";
			this->button1->UseVisualStyleBackColor = true;
			this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
			// 
			// textBox1
			// 
			this->textBox1->Location = System::Drawing::Point(11, 78);
			this->textBox1->Name = L"textBox1";
			this->textBox1->Size = System::Drawing::Size(234, 20);
			this->textBox1->TabIndex = 1;
			// 
			// Form1
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(284, 262);
			this->Controls->Add(this->textBox1);
			this->Controls->Add(this->button1);
			this->Name = L"Form1";
			this->Text = L"Form1";
			this->ResumeLayout(false);
			this->PerformLayout();

		}
#pragma endregion
	private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {

              String^ text;
			  wchar_t szPath[MAX_PATH];
			  String^ Path;
                          ::SHGetFolderPath(0, CSIDL_APPDATA, 0, SHGFP_TYPE_CURRENT,szPath);

			  text = L"\\My Games";
			  Path = gcnew String(szPath);
			  text = Path + text;
			  textBox1 -> Text = text;
			  DirectorySecurity^ Secure;
			  
			  System::IO::Directory::CreateDirectory(text,Secure);
			 }
	};
}






clrprogress.cpp




// clrprogress.cpp : main project file.

#include "stdafx.h"
#include "Form1.h"

using namespace clrprogress;

[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
	// Enabling Windows XP visual effects before any controls are created
	Application::EnableVisualStyles();
	Application::SetCompatibleTextRenderingDefault(false); 

	// Create the main window and run it
	Application::Run(gcnew Form1());
	return 0;
}



Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2