the root being returned is the name of the drive not the mapped letter.
Closed this issue · 1 comments
zhenglei-gao commented
I could not find someone having the same the problem but it seems after I select the root drive and then the target folder, only the name of the root drive is returned and what I can get by selecting the folder is
"EFM (V:)/XXX/2016/Effect modelling/"
I need the V:
instead of EFM (V:)
Below is the code I used:
library(shiny)
library(shinyFiles)
ui <- fluidPage( # Application title
mainPanel(
shinyDirButton("dir", "Input directory", "Upload"),
verbatimTextOutput("dir", placeholder = TRUE)
))
server <- function(input, output) {
shinyDirChoose(
input,
'dir',
## roots = c(home = 'C:/'),
roots = getVolumes()()
##filetypes = c('', 'txt', 'bigWig', "tsv", "csv", "bw")
)
global <- reactiveValues(datapath = getwd())
dir <- reactive(input$dir)
output$dir <- renderText({
global$datapath
})
observeEvent(ignoreNULL = TRUE,
eventExpr = {
input$dir
},
handlerExpr = {
if (!"path" %in% names(dir())) return()
#home <- normalizePath("~")
# browser()
global$datapath <-file.path(dir()$root,paste(unlist(dir()$path[-1]), collapse = .Platform$file.sep))
#file.path(home, paste(unlist(dir()$path[-1]), collapse = .Platform$file.sep))
})
}
# Run the application
shinyApp(ui = ui, server = server)
zhenglei-gao commented
I think I found the answer.
should be parseDirPath(root, input$directory)