|
|
|
JFileChooser и Мои документы
|
|||
|---|---|---|---|
|
#18+
У класса JFileChooser есть метод setCurrentDirectory, который устанавливает текущий каталог для выбора файла. Требуется указать папку Мои документы текущего пользователя Windows XP/2000. Как получить путь к ней? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 24.02.2005, 14:43 |
|
||
|
JFileChooser и Мои документы
|
|||
|---|---|---|---|
|
#18+
Мои документы располагаются по адресу: "<drive>:/Documents and Settings/<user_name>/My Documents" Таким образом Вам надо узнать диск на котором стоит система и имя пользователя. Диск можно узнать из переменной окружения WINDIR получив ее с помощью System.getenv(..); Таким же образом можно убедиться что программы запущена под Windows.... А вот "правильных" методов получить имя пользователя я не знаю.. Могу только посоветовать "неправильный" метод: посмотреть переменную окружения TEMP... тогда можно будет WINDIR не дергать.. но это плохой способ т.к TEMP можно легко изменить... ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 25.02.2005, 10:15 |
|
||
|
JFileChooser и Мои документы
|
|||
|---|---|---|---|
|
#18+
для имени пользователя можно попробывать изспользовать USERPROFILE переменную из переменных среды окружения (Env) ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 25.02.2005, 10:20 |
|
||
|
JFileChooser и Мои документы
|
|||
|---|---|---|---|
|
#18+
че то не понял, а это уже не катит: Код: plaintext 1. 2. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 25.02.2005, 10:34 |
|
||
|
JFileChooser и Мои документы
|
|||
|---|---|---|---|
|
#18+
Всем сенкью вери матч. Код: plaintext 1. То что нужно. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 25.02.2005, 11:19 |
|
||
|
JFileChooser и Мои документы
|
|||
|---|---|---|---|
|
#18+
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. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 25.02.2005, 11:36 |
|
||
|
JFileChooser и Мои документы
|
|||
|---|---|---|---|
|
#18+
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. Мне стало стыдно... ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 25.02.2005, 11:46 |
|
||
|
JFileChooser и Мои документы
|
|||
|---|---|---|---|
|
#18+
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. Мне стало стыдно... А мы вообще! Мы вообще не знаем куда нам скрыться! ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 25.02.2005, 11:59 |
|
||
|
JFileChooser и Мои документы
|
|||
|---|---|---|---|
|
#18+
GMaxМне стало стыдно... мне тоже :( ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 25.02.2005, 14:38 |
|
||
|
|

start [/forum/topic.php?fid=59&msg=32932657&tid=2152904]: |
0ms |
get settings: |
9ms |
get forum list: |
16ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
87ms |
get topic data: |
11ms |
get forum data: |
3ms |
get page messages: |
59ms |
get tp. blocked users: |
2ms |
| others: | 234ms |
| total: | 427ms |

| 0 / 0 |
