powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Java [игнор отключен] [закрыт для гостей] / JFileChooser и Мои документы
10 сообщений из 10, страница 1 из 1
JFileChooser и Мои документы
    #32931346
GMax
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
У класса JFileChooser есть метод setCurrentDirectory, который устанавливает текущий каталог для выбора файла.
Требуется указать папку Мои документы текущего пользователя Windows XP/2000.
Как получить путь к ней?
...
Рейтинг: 0 / 0
JFileChooser и Мои документы
    #32932657
foo
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
foo
Гость
Мои документы располагаются по адресу:

"<drive>:/Documents and Settings/<user_name>/My Documents"

Таким образом Вам надо узнать диск на котором стоит система и имя пользователя. Диск можно узнать из переменной окружения WINDIR получив ее с помощью System.getenv(..);
Таким же образом можно убедиться что программы запущена под Windows....

А вот "правильных" методов получить имя пользователя я не знаю..
Могу только посоветовать "неправильный" метод: посмотреть переменную окружения TEMP... тогда можно будет WINDIR не дергать.. но это плохой способ т.к TEMP можно легко изменить...
...
Рейтинг: 0 / 0
JFileChooser и Мои документы
    #32932677
Andrey Spirin
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
для имени пользователя можно попробывать изспользовать USERPROFILE переменную из переменных среды окружения (Env)
...
Рейтинг: 0 / 0
JFileChooser и Мои документы
    #32932729
Фотография Ося
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
че то не понял, а это уже не катит:


Код: plaintext
1.
2.
Properties sysProperties = System.getProperties();
String user = (String) sysProperties.get("user.home");
...
Рейтинг: 0 / 0
JFileChooser и Мои документы
    #32932893
GMax
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Всем сенкью вери матч.

Код: plaintext
1.
Properties sysProperties = System.getProperties();
String user = (String) sysProperties.get("user.home");

То что нужно.
...
Рейтинг: 0 / 0
JFileChooser и Мои документы
    #32932946
javadoc
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
GMaxУ класса JFileChooser есть метод setCurrentDirectory, который устанавливает текущий каталог для выбора файла.
Требуется указать папку Мои документы текущего пользователя Windows XP/2000.
Как получить путь к ней?

javadoc
setCurrentDirectory
--
public void setCurrentDirectory(File dir)

Sets the current directory. Passing in null sets the file chooser to point to the
user's default directory. This default depends on the operating system. It is typically
the "My Documents" folder on Windows, and the user's home directory on Unix. If the
file passed in as currentDirectory is not a directory, the parent of the file will be used
as the currentDirectory. If the parent is not traversable, then it will walk up the parent
tree until it finds a traversable directory, or hits the root of the file system.
...
Рейтинг: 0 / 0
JFileChooser и Мои документы
    #32932997
GMax
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
javadoc
setCurrentDirectory
--
public void setCurrentDirectory(File dir)

Sets the current directory. Passing in null sets the file chooser to point to the
user's default directory. This default depends on the operating system. It is typically
the "My Documents" folder on Windows, and the user's home directory on Unix. If the
file passed in as currentDirectory is not a directory, the parent of the file will be used
as the currentDirectory. If the parent is not traversable, then it will walk up the parent
tree until it finds a traversable directory, or hits the root of the file system.

Мне стало стыдно...
...
Рейтинг: 0 / 0
JFileChooser и Мои документы
    #32933058
GMax javadoc
setCurrentDirectory
--
public void setCurrentDirectory(File dir)

Sets the current directory. Passing in null sets the file chooser to point to the
user's default directory. This default depends on the operating system. It is typically
the "My Documents" folder on Windows, and the user's home directory on Unix. If the
file passed in as currentDirectory is not a directory, the parent of the file will be used
as the currentDirectory. If the parent is not traversable, then it will walk up the parent
tree until it finds a traversable directory, or hits the root of the file system.

Мне стало стыдно...

А мы вообще! Мы вообще не знаем куда нам скрыться!
...
Рейтинг: 0 / 0
JFileChooser и Мои документы
    #32933650
foo
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
foo
Гость
GMaxМне стало стыдно...

мне тоже :(
...
Рейтинг: 0 / 0
JFileChooser и Мои документы
    #32933669
foo GMaxМне стало стыдно...

мне тоже :(
спасибо :)
...
Рейтинг: 0 / 0
10 сообщений из 10, страница 1 из 1
Форумы / Java [игнор отключен] [закрыт для гостей] / JFileChooser и Мои документы
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]