Hi,
I have been trying to figure this out:
How do you remove more than one thing like this

remove("C:/Users/"+name+"/Documents/help");

How I want it to work is the users specify's there user name
and then it opens the C drive>Users>Then it needs to add the input user name.

Thanks.

Recommended Answers

All 3 Replies

Here is a .NET implementation of that:

// KillAFile.cpp : main project file.

#include "stdafx.h"

using namespace System;
using namespace System::IO;

int main(array<System::String ^> ^args)
{
	String^ strUser = "";
	//	 
	do
	{
		Console::WriteLine(L"Enter user ID");
	} while("" == (strUser = Console::ReadLine()));


	File::Delete("C:\\Users\\"+ strUser + "\\Documents\\help");

	return 0;
}

Thanks.
This is helpful but do you know how to do this in normal c++ code.
I am not that good with C# yet.

Thanks,
-Kioti16

Actually, that's not C#, it's C++ (dot net style).

Here's something older:

#include <stdio.h>
#pragma warning(disable : 4996) /* Microsoft _CRT_SECURE_NO_WARNINGS */
int main(void)
{
	char strUser[128] = {'\0'};
	char strPath[128] = {'\0'};
	
	do
	{
		printf("Enter user ID");
		gets(strUser);
	} while(NULL == strUser[0]);
	
	sprintf(strPath, "c:\\Users\\%s\\Documents\\help", strUser);
	unlink(strPath);
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.