AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 09.08.2012, 12:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,644 / 848 (80) +++++++
Регистрация: 28.10.2006
palleagermark: Combining file paths
Источник: http://palleagermark.blogspot.com/20...ile-paths.html
==============

When I develop something where file paths or file names must be combined, I’m always in doubt how to make sure backslashes are in the right place.

The simple example is when you need to combine a file path with a filename. Should the path end with a backslash or not? Did the user enter the path with an ending backslash or not in e.g. the parameters for the job?

You end up either ignoring one scenario or adding code to figure both out. This could eventual be a method where you decide it always returns the path with the ending backslash.

Well, in .NET there’s a static method, System.IO.Path.Combine, taking care of all this. You just pass it a number of paths and it ensures that backslashes are in the proper places in the returned string.

Here's a small example in X++:
static void PathCombine(Args _args)
{
str path1 = @"C:\TestDir";
str path2 = @"C:\TestDir\";
str path3 = "MyFolder";
str combination;

combination = System.IO.Path::Combine(path1, path3);

info (strFmt("Combinig '%1' with '%2' gives '%3'", path1, path3, combination));

combination = System.IO.Path::Combine(path2, path3);

info (strFmt("Combinig '%1' with '%2' gives '%3'", path2, path3, combination));
}



Источник: http://palleagermark.blogspot.com/20...ile-paths.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
palleagermark: Sample file import with StreamReader Blog bot DAX Blogs 0 11.01.2012 14:11
DynamicsAxSCM: Visualizing Security in Microsoft Dynamics AX 2012 Blog bot DAX Blogs 0 29.08.2011 13:11
Trace Parser. Error: Incorrect or missing MOF file, import is not available. Poleax DAX: Администрирование 6 13.05.2011 10:43
Microsoft Dynamics CRM Team Blog: Importing two or more entities from a Single File Blog bot Dynamics CRM: Blogs 0 09.11.2010 19:05
palleagermark: Creating an image file based on plain text from AX Blog bot DAX Blogs 0 03.03.2009 03:08

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 08:50.