Visual Studio 2010 Express에서 응용 프로그램을 만들었습니다. 먼저 디버그 버전을 컴파일하고 완벽하게 작동하지만 릴리스 버전을 컴파일 한 후에는 고정시킵니다.
내 응용 프로그램이 다음과 같이 작동해야합니다.
BIOS 버전을 모든 데스크톱에 수집했으며 자동으로 BIOS 버전을 업데이트합니다. 이들은 \ myserver \ bios_update와 같은 네트워크 공유에 있습니다. \\ myserver \ bios_update \ Log에 Log 폴더가 있습니다. 내 응용 프로그램은이 로그 폴더에 다음과 같은 방법으로 로그 파일을 만듭니다. \\ myserver \ bios_update \ log \ OptiPlex 780 \ hostname.txt 물론 OptiPlex 780은 PC의 모델 유형이며, 존재하지 않으면 많은 PC 모델 유형이 있기 때문에 만들어야합니다. hostname.txt (hostname이 컴퓨터 hostname으로 대체 된 경우)가 존재하지 않으면 해당 호스트 이름도 생성됩니다.릴리스 버전을 컴파일 한 후 이상한 행동으로 응용 프로그램이 시작됩니다.
흥미로운 부분은 지금까지는 문제가 없었지만 릴리스 버전을 컴파일 한 후 내 응용 프로그램이 다음과 같이 작동한다는 것입니다. hostname.txt가 있으면 제대로 작동하지만 그렇지 않으면 중지됩니다. 그것은 무한 루프에 들어가는 것과 같지만, 왜 (나는 어떤 데이터를 인쇄하고 내가 무한 루프를 말한 이유를 알고있다) 모르겠다.
내가 다음 사항주의 : 여기에 을 것입니다 내 응용 프로그램 동결 : (folderexists (LogFolder가)) LogFolder이 MYSERVER가 bios_update \ 로그인 \ 이 hostname.txt하지 존재 않습니다 \ 경우 \\ 같은 경로를 포함하는 경우, 내 앱이 정지되지만, 존재한다면 괜찮습니다. 또한 마지막 \ like \ myserver \ bios_update \ Log없이 LogFolder를 제공하면 괜찮습니다. 그것은 나를 미치게 그리고 내가 문제가 무엇인지, 그것을 알아낼 수 없기 때문에 어떤 조언이 appritiatedbool folderexists(char * foldername)
{
if (_access(foldername, 0) == 0)
{
struct stat status;
stat(foldername, &status);
if (status.st_mode & S_IFDIR)
{
//cout << "\nThe directory exists." << endl;
return true;
}
else
{
//cout << "\nThe path you entered is a file." << endl;
WriteToLog("The path you entered is a file??????????????????", false);
return false;
}
}
else
{
//cout << "\nPath doesn't exist." << endl;
return false;
}
}//folderexists
void WriteToLog(char * text, bool star)
{
char time[ SMALL ], LogModel[ MEDIUM ], Day[ SMALL ], Month[ SMALL ];
FILE *logfile;
memset(time, 0, sizeof(time));
memset(Day, 0, sizeof(Day));
memset(Month, 0, sizeof(Month));
SYSTEMTIME lt;
GetLocalTime(<);
GetDayAndMonth(lt.wDayOfWeek , Day, lt.wMonth, Month);
sprintf(time, "[%s %s %d %02d:%02d:%02d]", Day, Month, lt.wDay, lt.wHour, lt.wMinute, lt.wSecond);
//printf("\nThe local time is: %02d:%02d\n", lt.wHour, lt.wMinute);
if (!file_exists(LogFile))
{
memset(LogModel, 0, sizeof(LogModel));
strcpy(LogModel, LogFolder);
strcat(LogModel, PCModel);
if (folderexists(LogFolder)) <== Here is where my App freeze!!!!!!!
{
if (!folderexists(LogModel))
{
if (!CreateDirectoryA(LogModel, NULL)) ShowError("CreateDirectoryA .............................. Failed! (creating LogModel folder) ", true, true);
}
}
else
{
printf("\nLogFolder isn't reachable!");
exit(-1);
}
}//file_exists
if ((logfile = fopen(LogFile, "a")) == NULL)
{
ShowError("Failed to create Logfile!", false, true);
}
else
{
fputs(time, logfile);
fputs(" - ", logfile);
fputs(text, logfile);
fputs("\n", logfile);
if (star) fputs("**********************************************************************************************************************\n", logfile);
fclose(logfile);
//if (star) exit(-1);
}
}//WriteToLog
: 다음은 내 코드입니다.
젠장! 당신 말이 맞아요! 어떻게 내가 이것을 놓칠 수 있니? 그러나 이것은 내 문제의 일부일뿐입니다. 디버그 버전에서 작동하는 이유와 릴리스 버전에서 작동하지 않는 이유를 이해할 수 없습니다. LogFolder에 끝에 \를 붙이면 driectory를 찾을 수 없지만 thedbug 버전에서는 찾았습니다. – kampi
@kampi 디버그/릴리스 차이점에 대해 질문하지 않기를 바랬다. 나는 C/C++ 사용자가 아니기 때문에 릴리스와 디버그가 어떻게 동작을 바꿀지 전혀 모른다. – rene
미안하지만 :) 미쳤어. Folderexists 반환 "당신이 입력 한 경로는 거의 항상 파일입니다"나는 왜 그런지 모르겠다 : ( – kampi